On Sun, 14 Mar 2010 22:04:18 +0000, Simon Slavin <slav...@bigfraud.org> wrote:
> I was trying to work out if I could add a FOREIGN KEY to a table after > it is originally created, using the ALTER TABLE command. I think there's an > error on > >http://www.sqlite.org/syntaxdiagrams.html > > I cannot find anything on that page that includes the actual words 'FOREIGN > KEY'. The section > >http://www.sqlite.org/syntaxdiagrams.html#foreign-key-clause > > starts with the word 'REFERENCES'. I traced up and down the hierarchy > but I couldn't find 'FOREIGN KEY'. This is not consistent with the > description of creating FK constraints as described in > >http://www.sqlite.org/foreignkeys.html Well, it is consistent, when you take http://www.sqlite.org/syntaxdiagrams.html#table-constraint into account. CREATE TABLE is the only statement where references constraints can be defined. Have a look at http://www.sqlite.org/lang_createtable.html A column definition can contain a foreign-key-clause, which is simply a REFERENCES column-constraint. In a table-constraint (defined after all column definitions) a REFERENCES constraint is introduced by the FOREIGN KEY keyword. The difference between the two is that a table constraint can (but doesn't have to) use composite keys, consisting of more than one column. >Simon. -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users