SQLite ALTER TABLE-在现有列之间添加列? [英] Sqlite ALTER TABLE - add column between existing columns?

查看:329
本文介绍了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.

这篇关于SQLite ALTER TABLE-在现有列之间添加列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆