如何在现有表格的特定位置插入列?
我创建了一个有85列的表格,但是我错过了一列.错过的栏应该是第57栏.我不想删除该表并再次创建它.我希望编辑该表并在第57个索引中添加一列.
I created a table with 85 columns but I missed one column. The missed column should be the 57th one. I don't want to drop that table and create it again. I'm looking to edit that table and add a column in the 57th index.
我尝试了以下查询,但在表末尾添加了一列.
I tried the following query but it added a column at the end of the table.
ALTER table table_name
Add column column_name57 integer
如何将列插入特定位置?
How can I insert columns into a specific position?
ALTER TABLE
默认情况下在表的末尾添加新列.使用AFTER
指令将其放置在表格中的某个位置:
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 table_name
Add column column_name57 integer AFTER column_name56
来自mysql文档
要在表行中的特定位置添加一列,请使用
FIRST
或AFTER
col_name
.默认为最后添加该列.您还可以在CHANGE
或MODIFY
操作中使用FIRST
和AFTER
对表中的列进行重新排序.
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.
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
I googled for this for PostgreSQL but it seems to be impossible.