I created a table with 85 columns but i missed one column. The missed column should be 57th row (column's place). I don't want to drop that table and don't want to create it again, I need to edit that table and i have to add that column in 57th row
我创建了一个包含85列的表,但我错过了一列。错过的列应该是第57行(列的位置)。我不想删除该表,也不想再创建它,我需要编辑该表,我必须在第57行添加该列
ALTER table table_name
Add column column_name57 integer
How to call that column in 57th row
如何在第57行调用该列
6 个解决方案
#1
39
ALTER TABLE
by default adds new columns at the end of the table. Use the AFTER
directive to place it in a certain position within the table:
默认情况下,ALTER TABLE会在表的末尾添加新列。使用AFTER指令将其放在表格中的某个位置:
ALTER table table_name
Add column column_name57 integer AFTER column_name56
From mysql doc
来自mysql doc
To add a column at a specific position within a table row, use
FIRST
orAFTER
col_name
. The default is to add the column last. You can also useFIRST
andAFTER
inCHANGE
orMODIFY
operations to reorder columns within a table.要在表格行中的特定位置添加列,请使用FIRST或AFTERcol_name。默认是最后添加列。您还可以在CHANGE或MODIFY操作中使用FIRST和AFTER重新排序表中的列。
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
I googled for this for PostgreSQL but it seems to be impossible.
我为PostgreSQL搜索了这个,但似乎不可能。
#3
1
ALTER TABLE table_name ADD COLUMN column_name57 INTEGER AFTER column_name56
#4
0
ALTER TABLE table_name ADD COLUMN column_name integer
#5
0
if you are saying ADD COLUMN column_name then it will throw error
如果你说ADD COLUMN column_name那么它会抛出错误
u have to try
你必须尝试
ALTER TABLE temp_name ADD My_Coumn INT(1) NOT NULL DEFAULT 1
remember if table already has few record and u have to create new column then either u have to make it nullable or u have to define the default value as I did in my query
记住,如果表已经有很少的记录,你必须创建新的列然后你必须让它可以为空或你必须像我在我的查询中那样定义默认值
#6
-1
I tried to alter the table like so:
我试着改变这样的表:
table_name add column column_name after column column_name;
The first column_name
is the new column name, the second column_name
is the existing column where you plan to insert into after.
第一个column_name是新列名,第二个column_name是您计划在之后插入的现有列。
#1
39
ALTER TABLE
by default adds new columns at the end of the table. Use the AFTER
directive to place it in a certain position within the table:
默认情况下,ALTER TABLE会在表的末尾添加新列。使用AFTER指令将其放在表格中的某个位置:
ALTER table table_name
Add column column_name57 integer AFTER column_name56
From mysql doc
来自mysql doc
To add a column at a specific position within a table row, use
FIRST
orAFTER
col_name
. The default is to add the column last. You can also useFIRST
andAFTER
inCHANGE
orMODIFY
operations to reorder columns within a table.要在表格行中的特定位置添加列,请使用FIRST或AFTERcol_name。默认是最后添加列。您还可以在CHANGE或MODIFY操作中使用FIRST和AFTER重新排序表中的列。
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
I googled for this for PostgreSQL but it seems to be impossible.
我为PostgreSQL搜索了这个,但似乎不可能。
#2
#3
1
ALTER TABLE table_name ADD COLUMN column_name57 INTEGER AFTER column_name56
#4
0
ALTER TABLE table_name ADD COLUMN column_name integer
#5
0
if you are saying ADD COLUMN column_name then it will throw error
如果你说ADD COLUMN column_name那么它会抛出错误
u have to try
你必须尝试
ALTER TABLE temp_name ADD My_Coumn INT(1) NOT NULL DEFAULT 1
remember if table already has few record and u have to create new column then either u have to make it nullable or u have to define the default value as I did in my query
记住,如果表已经有很少的记录,你必须创建新的列然后你必须让它可以为空或你必须像我在我的查询中那样定义默认值
#6
-1
I tried to alter the table like so:
我试着改变这样的表:
table_name add column column_name after column column_name;
The first column_name
is the new column name, the second column_name
is the existing column where you plan to insert into after.
第一个column_name是新列名,第二个column_name是您计划在之后插入的现有列。