Re: [sqlite] 2 columns as primary key?
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
Re: [sqlite] 2 columns as primary key?
Thanks! It worked. Sorry for the silly question :) Igor Tandetnik wrote: > ""Andrés G. Aragoneses"" >wrote in message > news:gvq7b2$lp...@ger.gmane.org >> CREATE TABLE LastSyncedRatings ( >> DapID TEXT PRIMARY KEY, >> MetadataHashTEXT PRIMARY KEY, >> Rating INTEGER NOT NULL >> ) > > Make it > > CREATE TABLE LastSyncedRatings ( > DapID TEXT , > MetadataHashTEXT, > Rating INTEGER NOT NULL, > PRIMARY KEY(DapID, MetadataHash) > ); > > Igor Tandetnik > > > > > > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 2 columns as primary key?
create table tablename ( colname1 coltype, colname2 coltype, colname3 coltype, PRIMARY KEY(colname1 asc, colname2 asc) ) --- On Fri, 5/29/09, Pavel Ivanov <paiva...@gmail.com> wrote: From: Pavel Ivanov <paiva...@gmail.com> Subject: Re: [sqlite] 2 columns as primary key? To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> Date: Friday, May 29, 2009, 10:54 PM What create table statement did you use? Pavel 2009/5/29 "Andrés G. Aragoneses" <kno...@gmail.com>: > 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 > > Andres > > -- > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 2 columns as primary key?
""Andrés G. Aragoneses""wrote in message news:gvq7b2$lp...@ger.gmane.org > CREATE TABLE LastSyncedRatings ( > DapID TEXT PRIMARY KEY, > MetadataHashTEXT PRIMARY KEY, > Rating INTEGER NOT NULL > ) Make it CREATE TABLE LastSyncedRatings ( DapID TEXT , MetadataHashTEXT, Rating INTEGER NOT NULL, PRIMARY KEY(DapID, MetadataHash) ); Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 2 columns as primary key?
CREATE TABLE LastSyncedRatings ( DapID TEXT PRIMARY KEY, MetadataHashTEXT PRIMARY KEY, Rating INTEGER NOT NULL ) Pavel Ivanov wrote: > What create table statement did you use? > > Pavel > > 2009/5/29 "Andrés G. Aragoneses": >> 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 >> >>Andres >> >> -- >> >> ___ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] 2 columns as primary key?
What create table statement did you use? Pavel 2009/5/29 "Andrés G. Aragoneses": > 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 > > Andres > > -- > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] 2 columns as primary key?
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 Andres -- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users