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

问题描述:

如果我有一个包含列的表:a,b,c,然后再执行ALTER TABLE命令以添加新列 d,是否可以在例如a和b之间添加它,而不是在结束?

If I have a table with columns: a, b, c and later I do a ALTER TABLE command to add a new column "d", is it possible to add it between a and b for example, and not at the end?

我听说列的位置会影响性能。

I heard that the position of the columns affects performance.

使用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.