I have a strange error in Postgres during creation of sequence and linking on existing table.
I tried to execute the following script on existing DB which have a schema named 'testschema':
BEGIN TRANSACTION;
CREATE TABLE testschema.mytable (
id INTEGER,
value VARCHAR(30),
CONSTRAINT pk_mytable PRIMARY KEY (id));
CREATE SEQUENCE testschema.mytable_id_seq;
ALTER TABLE testschema.mytable ALTER COLUMN id SET NOT NULL;
ALTER TABLE testschema.mytable ALTER COLUMN id SET DEFAULT nextval('mytable_id_seq');
COMMIT;
I got the following error for the second ALTER TABLE query:
********** Erreur **********
ERREUR: la relation « mytable_id_seq » n'existe pas État SQL :42P01
Error message can be translated by "Relation 'mytable_id_seq' does not exist".
If I try to execute this script without schema (i.e. in the public schema), it works.
I don't understand what it is failing. Does anyone see where the problem is?
Thanks for your help.