-
MySQL ALTER TABLE Query
Hiya!
Hopefully this is a nice easy one. I'm trying to add a new column to a table. Not difficult. But I want to insert it in a specific position in the table. I can't find a simple way to do this - but there MUST be one, right?
Cheers
-
New column added with ALTER statement always gets added at the end. Only way to put it in the middle is recreate the table.
-
thanks. so I can make a temporary table containing all my original columns PLUS the new columns inserted in the correct positions. is there an easy way to copy the contents of the old table into the correct columns in the new table? some form of JOIN statement perhaps...? obviously I can do this with a simple script but I have quite a lot of columns and if there's an automated method that'd be much easier...
Last edited by el_numptio; 03-24-2003 at 09:41 AM.
-
No, you can add a column wherever you want. Use something like:
ALTER TABLE t ADD f2 TINYINT NOT NULL AFTER f1;
-
GUI Alternative
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|