In documentation of postgreSQL 9.6, it said to have serial equivalent we have to link the sequence to the field.
https://www.postgresql.org/docs/9.6/datatype-numeric.html (¤ 8.1.4)
I exactly applied the same code :
CREATE SEQUENCE seq_import_trame INCREMENT 1 START 1;
CREATE TABLE import_trame (
id integer NOT NULL DEFAULT nextval('seq_import_trame'),
...,
CONSTRAINT pk_import_trame PRIMARY KEY (id)
);
ALTER SEQUENCE seq_import_trame OWNED BY import_trame.id;
But I have an error while executing script with pgAdmin.
Relation "seq_import_trame" already exist".
Code: 42P07
Line 8: ALTER SEQUENCE.....
It's very strange because 42P07 error is duplicate_table. And if we don't make the link, the sequence is not dropped when we drop the table.
Any idea ?
create sequencepartCREATE SEQUENCE IF NOT EXISTS ....