I'm trying to create a system, where I'm wanna sort the data for years (using schemas), for example now I have a schema named datos_2016 then I create a sequence named seq_datos.
When I try to create the table datos and set the sequence for cdata it says
"An error has ocurred: ERROR The relation "seq_data" doesn't exits"
But if I create the schema "public" and then create the sequence there, no error happens (the table is successfully created).
Why can't I create sequences in another schema?
The SQL CODE:
CREATE TABLE datos_2016.data
(
cdata integer NOT NULL DEFAULT nextval('seq_data'),
CONSTRAINT fk_cdata PRIMARY KEY (cdata) USING INDEX TABLESPACE sistema_index
)
WITH (
OIDS = FALSE
)
TABLESPACE sistema_data;
The Sequence Code:
CREATE SEQUENCE datos_2016.seq_data
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE datos_2016.seq_data
OWNER TO postgres;
GRANT ALL ON SEQUENCE datos_2016.seq_data TO public;
GRANT ALL ON SEQUENCE datos_2016.seq_data TO postgres;