Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the below SQL I am trying to use to create a table and some columns. As part of it, I want two of the columns to autoincrement an integer. When I try using the below code it gives me an error.

    CREATE TABLE IF NOT EXISTS 'tasks' (
'rowID' INTEGER, 
'gID' INTEGER, 
'task' TEXT, 
'status' TEXT, 
'position' INTEGER, 
'updated' INTEGER, 
'inlist' TEXT, 
'deleted' TEXT, 
PRIMARY KEY AUTOINCREMENT ('rowID','position')
)

When I remove the keyword "AUTOINCREMENT" from the SQL it works fine.

Is it possible to have two autoincrementing columns? If not, is there a way I can have one column automatically take the value from the other (auto-incrementing) column as its being inserted?

Thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
407 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can't have two autoincrement fields. You should use a single autoincrement field. Given that both fields would always have the same value for every row, there's no reason to have to such fields anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...