user1154644
user1154644

Reputation: 4609

Defining a composite primary key in h2

How can I specify that a table has multiple columns that makeup the primary key? When I run this sql statement, I get "unknown data type "("

CREATE TABLE SH_LEAGUE_CONTACT_TEAM_ROLE(ROLE_NAME VARCHAR NOT NULL,
TEAM_ID INT NOT NULL,
CONTACT_ID INT NOT NULL,
FOREIGN_KEY(TEAM_ID) REFERENCES SH_LEAGUE_TEAM(ID),
FOREIGN_KEY(CONTACT_ID) REFERENCES SH_LEAGUE_CONTACT(ID),
PRIMARY KEY(ROLE_NAME, TEAM_ID, CONTACT_ID));

Upvotes: 6

Views: 13840

Answers (1)

Thomas Mueller
Thomas Mueller

Reputation: 50087

You have a typo in your statement, you have used FOREIGN_KEY (one word) instead of FOREIGN KEY (two words).

Upvotes: 7

Related Questions