I'm having an issue where I used pgAdmin4's GUI to create a SQL table, and I want to use to generated CREATE TABLE
script to create this same table in another database.
When I run the CREATE TABLE
script generated by pgAdmin4 in my new database, I get the following error:
ERROR: relation "schema.TableName_Id_seq" does not exist
So, it appears that the issue is with my auto-incrementing id column that I created as type SERIAL
.
The CREATE TABLE
script as provided by pgAdmin4:
-- Table: myschema.TableName
-- DROP TABLE myschema."TableName";
CREATE TABLE myschema."TableName"
(
"Id" integer NOT NULL DEFAULT nextval('myschema."TableName_Id_seq"'::regclass),
/* Other columns here */
CONSTRAINT "TableName_pkey" PRIMARY KEY ("Id")
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE myschema."TableName"
OWNER to JoshuaSchlichting;
Why can't the CREATE TABLE
script be used in another database? The relation "schema.TableName_Id_seq"
didn't exist in the original database prior to be creating that table. What's happening that is different?