MySQL "alter table" syntax got problemI am trying to add a column into an existing table using
ALTER TABLE table_name ADD COLUMN column_name column_definition FIRST another_column
the FIRST keyword got syntax error.
btw, i am using MySQL 4
Could anyone help to solve this problem?
[喔喔 (5-12 16:06, Long long ago)]
[ 传统版 |
sForum ][登录后回复]1楼
alter table my_table add column my_colunm varchar(eg) default "default";[MrDJay (5-13 12:01, Long long ago)] [ 传统版 | sForum ][登录后回复]2楼
(引用 MrDJay:alter table my_table add column my_colunm varchar(eg) default "default";)actually ur this sql query only insert a new column at the end of the tablewhat i want is to insert a new column at the beginning of the table.
And, i just found out that there is no problem with the keyword "FIRST" at all. I read the manual wrongly yesterday.
======================
ALTER [IGNORE] TABLE tbl_name alter_specification [, alter_specification] ...
alter_specification:
ADD [COLUMN] column_definition [FIRST | AFTER col_name ]
....
.....
=======================
So, to add a column at the beginning of the table, use "alter table my_table add column my_colunm column_definition FIRST". To add a column at any other place rather than the beginning of the table, use "table my_table add column my_colunm column_definition AFTER clolumn_B"
[喔喔 (5-14 9:25, Long long ago)]
[ 传统版 |
sForum ][登录后回复]3楼
(引用 喔喔:actually ur this sql query only insert a new column at the end of the tablewhat i want is to insert a new column at the beginnin
...)ic, sorrydid not tell from your first post that you want to /have to insert it at the beginning of the table :P
[MrDJay (5-14 11:16, Long long ago)]
[ 传统版 |
sForum ][登录后回复]4楼