alter table drop column syntax error using sqlite

大城市里の小女人 提交于 2019-12-03 15:54:14

问题


This is the schema of my table:

create table LPCG(ID integer primary key, PCG text, Desc text, test text);

I wish to drop the column "test", and hence use the command:

alter table LPCG drop column test;

This is the error message I get:

Error: near "drop": syntax error

Can someone please help me correct my error?

An additional question is: I understand that ID is the primary key attribute. Would I be able to drop that column? If not, is there a workaround which anyone has used?

Thanks in advance for any help.


回答1:


SQLite does not fully support ALTER TABLE statements. You can only rename table, or add columns.

If you want to drop a column, your best option is to create a new table without the column, and to drop the old table in order to rename the new one.



来源:https://stackoverflow.com/questions/6268064/alter-table-drop-column-syntax-error-using-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!