Composite primary key definition syntax in H2 Database engine

-1

I'm trying to set a primary key consisting of two columns when creating a table in the H2 Database Engine ( link ) , but I did not find the syntax in the manual. Could you give me tips? For example: the syntax in MySql, Postgress ... Maybe some work ...

I've tried:

CREATE TABLE CONTACORRENTE (AGENCIA INT PRIMARY KEY, NUMERO INT PRIMARY KEY)

But H2 does not recognize as a compound key (says that it is not possible to define two primary keys) ...

    
asked by anonymous 23.07.2018 / 23:13

1 answer

1

Try this:

CREATE TABLE  CONTACORRENTE (
    Agencia INT NOT NULL,
    Numero  INT NOT NULL,

 CONSTRAINT [PK_CONTACORRENTE] PRIMARY KEY (
    Agencia,Numero 
 )
)
    
24.07.2018 / 12:06