开发者

SQLite INSERT command Syntax Help

Greetings All,

I have a SQLite database that I'm trying to add a new column to an existing table. My curren开发者_如何学运维t structure is:

ID_NO, integer GUIDE, integer MATERIAL, text

I would like to add a new column which is the first letter of MATERIAL KEY, text

Here is what I tried, but I get an error that MATERIAL doesn't exist

INSERT INTO ERG_DATA (KEY) VALUES ( SUBSTR(MATERIAL,1,1))

Is INSERT the right command? Any help would be appreciated. Thanks in advanced!


From the top of my head, you want something like this (two commands)

ALTER TABLE erg_data ADD COLUMN key CHAR(1);
UPDATE erg_data SET key = SUBSTR(material, 1, 1);


Haven't worked with SQLite, but in general an Insert statement is used to write data into the table, not change the table definition.

If you want to change the definition of the table, you should look for an Alter statement instead, like Alter Table [tablename] Add Column [columnname] [datatype]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜