On 30/05/2009 12:43 PM, Andrés G. Aragoneses wrote:
> I just tried to create a primary key with 2 columns and got this error:
> 
> "sqlite error" "table X has more than one primary key"
> 
> 
> Doesn't SQLite support this?? :o

It does support multi-column primary keys. It's a bit hard to tell at 
this distance what your problem is. Unfortunately, as the text of your 
CREATE TABLE statement is presumably a state secret, we'll have to play 
guessing games:

dos-prompt>sqlite3
SQLite version 3.6.14
Enter ".help" for instructions
Enter SQL statements terminated with a ";"

Example of supporting multi-column primary keys:

sqlite> create table employment (employer_id text, employee_id text, 
start_date datetime, primary key (employer_id, employee_id));

Example of getting your error message:

sqlite> create table employment2 (employer_id text primary key, 
employee_id text primary key, start_date datetime);
SQL error: table "employment2" has more than one primary key
sqlite>

Are we getting warm?

Suggested reading:

http://www.firstsql.com/tutor6.htm#constraint
http://www.sqlite.org/syntaxdiagrams.html#table-constraint
http://www.catb.org/~esr/faqs/smart-questions.html

HTH,
Hohn
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to