且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLite ALTER TABLE-在现有列之间添加列?

更新时间:2023-11-30 18:48:16

使用SQLite中的ALTER TABLE语句无法在两个现有列之间添加列。此按设计工作

It's not possible to add a column between two existing columns with an ALTER TABLE statement in SQLite. This works as designed.


新列始终附加在现有
列列表的末尾。

The new column is always appended to the end of the list of existing columns.

据我所知,MySQL是允许您确定新列的位置

As far as I know, MySQL is the only SQL (ish) dbms that lets you determine the placement of new columns.


要在表行中的特定位置添加列,请使用FIRST
或之后的col_name。默认为最后添加该列。您还可以
在CHANGE或MODIFY操作中使用FIRST和AFTER对表中的列
进行重新排序。

To add a column at a specific position within a table row, use FIRST or AFTER col_name. The default is to add the column last. You can also use FIRST and AFTER in CHANGE or MODIFY operations to reorder columns within a table.

但这不是我经常使用的功能,因此据我所知并不是很远。

But this isn't a feature I'd use regularly, so "as far as I know" isn't really very far.