473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Changing an individual field

Ike
Suppose I have a table, and it is populated with many rows already. However,
I realise I structured something wrong in my table. I dont want to have to
go back and repopulate the entire table.

For example, suppose I have a field:

"inoutstatus INTEGER(3),"

Which I now realize should be :

"inoutstatus CHAR(1),"

Is there a way I can change the entire table without losing the other
records in each row? I can go back in and repopulate the inoutstatus fields,
but I really would like to know if there is merely some type of SQL command
I can issue to restructure the table this way.

Thanks, Ike
Jul 19 '05 #1
3 3920
Ike wrote:
Suppose I have a table, and it is populated with many rows already. However,
I realise I structured something wrong in my table. I dont want to have to
go back and repopulate the entire table.

For example, suppose I have a field:

"inoutstatus INTEGER(3),"

Which I now realize should be :

"inoutstatus CHAR(1),"

Is there a way I can change the entire table without losing the other
records in each row? I can go back in and repopulate the inoutstatus fields,
but I really would like to know if there is merely some type of SQL command
I can issue to restructure the table this way.


Atleast you can drop off one field and then add it to your table. But
afaik it will be at the end of your table. ( If the order of columns
happens to matter you(?) )

# remove old column
alter table [tablename] drop column inoutstatus;

# add new column
alter table [tablename] add column inoutstatus char(1);

I don't know if there is another way to do this.

Jul 19 '05 #2
DCB
"Aggro" <sp**********@yahoo.com> wrote in message
news:Je***************@read3.inet.fi...
: Atleast you can drop off one field and then add it to your table. But
: afaik it will be at the end of your table. ( If the order of columns
: happens to matter you(?) )
:
: # remove old column
: alter table [tablename] drop column inoutstatus;
:
: # add new column
: alter table [tablename] add column inoutstatus char(1);
:
: I don't know if there is another way to do this.
Hi, back up first then try

ALTER TABLE
'tablename'
CHANGE
'inoutstatus' 'inoutstatus'
CHAR(1)
http://www.mysql.com/doc/en/ALTER_TABLE.html
hth
Jul 19 '05 #3
DCB
"Aggro" <sp**********@yahoo.com> wrote in message
news:Je***************@read3.inet.fi...
: Atleast you can drop off one field and then add it to your table. But
: afaik it will be at the end of your table. ( If the order of columns
: happens to matter you(?) )
:
: # remove old column
: alter table [tablename] drop column inoutstatus;
:
: # add new column
: alter table [tablename] add column inoutstatus char(1);
:
: I don't know if there is another way to do this.
Hi, back up first then try

ALTER TABLE
'tablename'
CHANGE
'inoutstatus' 'inoutstatus'
CHAR(1)
http://www.mysql.com/doc/en/ALTER_TABLE.html
hth
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ike | last post by:
Suppose I have a table, and it is populated with many rows already. However, I realise I structured something wrong in my table. I dont want to have to go back and repopulate the entire table. ...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
3
by: Geoff Matthews | last post by:
I apologize for the basic question, but MS's documentation has been no help at all. I'm working on a database, and need to create a form for schedules, M-F, 8-4. I've settled on an easy way out,...
5
by: David | last post by:
Hi I seem to be getting nowhere with this. I am opening a form which will be used to input Notes into different fields in a table. My problem is changing the unbound field name to the field name...
32
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
7
by: owolablo | last post by:
Can anybody please tell me how to change the individual elements of a char variable. I need to parse through the string, check for a particular character and change it to something else if it is...
17
by: blufox | last post by:
Hi All, Can i change the execution path of methods in my process at runtime? e.g a()->b()->c()->d()->e() Now, i want execution to be altered at runtime as -
3
by: Deano | last post by:
I have a nice report that uses sql to report employee absences. I grab the employee and related absence data using the employee id field which is unique. I use the employee id as a header on...
7
by: sphinney | last post by:
I have a datasheet style form with textbox (MyTextBox) that has the Text Format property set to "Rich Text". It is bound to a memo field in a table. How do I change the text or highlight color of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.