[Monetdb-developers] SERIAL column,

Romulo Goncalves R.A.Goncalves at cwi.nl
Wed May 9 15:03:53 CEST 2007


Good afternoon,

sql>create table t1 (id SERIAL, PRIMARY KEY(id));
MAPI  = monetdb at localhost:50000
QUERY = create table t1 (id SERIAL, PRIMARY KEY(id));
ERROR = !CONSTRAINT PRIMARY KEY: a table can have only one PRIMARY KEY
sql>create table t1 (id SERIAL);
sql>insert into t1 values(5);
[ 1     ]
sql>insert into t1;
[ 1     ]
sql>insert into t1;
[ 1     ]
sql>insert into t1;
[ 1     ]
sql>insert into t1;
[ 1     ]
sql>insert into t1;
MAPI  = monetdb at localhost:50000
QUERY = insert into t1;
ERROR = !SQLException:assert:INSERT INTO: PRIMARY KEY constraint 
't1.t1_id_pkey' violated
sql>

The constraint check is correct, but should the first insertion be allowed?

I checked the parser to know what SERIAL means:

|  column SERIAL
                 { /* SERIAL = INTEGER GENERATED ALWAYS AS IDENTITY 
PRIMARY KEY */

Then I check what means GENERATED ALWAYS means:

http://troels.arvin.dk/db/rdbms/#mix-identity

"When ALWAYS is specified, the user cannot specify a value for the 
column which means that the DBMS can guarantee successful insertion of a 
unique value on each table insert."

Who is right? The web-page or MonetDB?

I tried to find something in the standard book and nothing (maybe I did 
not check correctly).

Regards,
Romulo




More information about the developers-list mailing list