On Jan 6, 2009, at 2:27 PM, ssecorp wrote:
On Jan 6, 8:12 pm, ssecorp <circularf...@gmail.com> wrote:CREATE TABLE foo ( col1 INTEGER NOT NULL, col2 VARCHAR(32) NOT NULL, col3 DATE NOT NULL, PRIMARY KEY (col1, col2) ); how would I set primary key if it is a combination of 2 keys?
You specify it as you would specify it in straight SQL. All that sql/ create-table is doing here is providing a way to structure things a bit more fluidly than as one big string.
also how would I set a key to be both foreign and primary //////////////////////////////////// (defn create-toast [] (sql/create-table :toast [:customerid :int "primary key"] [:movieid :int "foreign key"] [:reviewdate "DATE"] [:grade :int])) user=> java.lang.Exception: transaction rolled back: Syntax error: Encountered "foreign" at line 1, column 61. (db.clj:0)
Based one http://db.apache.org/derby/docs/10.2/ref/rrefsqlj13590.html#rrefsqlj13590 , it appears that the syntax for foreign key columns begins with "foreign key". My example was incorrect.
--Steve
smime.p7s
Description: S/MIME cryptographic signature