使用sqlite更改表放置列语法错误 [英] alter table drop column syntax error using sqlite

查看:110
本文介绍了使用sqlite更改表放置列语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的表的架构:

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

我希望删除 test列,因此使用以下命令:

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有人请帮助我纠正错误吗?

Can someone please help me correct my error?

另一个问题是:我知道ID是主键属性。我可以删除该列吗?如果没有,那么有没有人使用过的解决方法?

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?

在此先感谢您的帮助。

推荐答案

SQLite不完全支持 ALTER TABLE 语句。您只能重命名表或添加列。

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.

这篇关于使用sqlite更改表放置列语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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