On 5/07/2009 5:49 AM, James Scott wrote: > I have the following: > > CREATE TABLE [Sections] ( > [Department] varchar NOT NULL COLLATE NOCASE, > [Course] varchar NOT NULL COLLATE NOCASE, > [Section] varchar NOT NULL COLLATE NOCASE, > [Class_Time] timestamp, > [I_Id] varchar COLLATE NOCASE, > [Room] varchar COLLATE NOCASE, > CONSTRAINT [sqlite_autoindex_Sections_1] PRIMARY KEY ([Department], > [Course], [Section])); > > CREATE INDEX [PK_Sections] ON [Sections] ([Department], [Course], [Section]);
Ummm, after those two statements, you have TWO indexes on your 3 fields. sqlite> .header on sqlite> select * from sqlite_master where type = 'index'; type|name|tbl_name|rootpage|sql index|sqlite_autoindex_Sections_1|Sections|3| index|PK_Sections|Sections|4|CREATE INDEX [PK_Sections] ON [Sections] ([Department], [Course], [Section]) sqlite> What are you trying to achieve? > In the programming language, I need to refer to the primary key as 1 field. And "the programming language" (why the mystery? which language?) doesn't support concatenation of strings? Or better, e.g. Python's tuple pk = (department, course, section) which can be used as a dictionary key or a set element or a sort key or ... and can be easily picked apart to recover the parts: department, course, section = pk > Does Sqlite allow a 'calculated field', such as concatenation of the 3 > columns in the PK? Of course. SQL has allowed it since the year dot. http://www.sqlite.org/syntaxdiagrams.html#result-column "expr" => expression ... do what you want. HTH, John _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users