-
Notifications
You must be signed in to change notification settings - Fork 821
Description
For ease, I'll prepare the example tables by script:
CREATE TABLE parent
(
"UUID" uuid NOT NULL DEFAULT gen_random_uuid(),
"parentField" text,
"entryType" integer NOT NULL DEFAULT 0,
CONSTRAINT "parent_pkey" PRIMARY KEY ("UUID")
)
;
CREATE TABLE child
(
"childField" text
)
INHERITS (parent)
;
ALTER TABLE child
ADD PRIMARY KEY ("UUID");
ALTER TABLE child
ALTER COLUMN "entryType" SET DEFAULT 1;
ALTER TABLE child
ALTER COLUMN "parentField" SET DEFAULT 'child';
ALTER TABLE child
ALTER COLUMN "childField" SET DEFAULT 'child';
Now I'll create the "CREATE"-script for table "child". It should create the same layout as is, including the changed parts depending on the inherited columns:
-- Table: public.child
-- DROP TABLE IF EXISTS public.child;
CREATE TABLE IF NOT EXISTS public.child
(
-- Inherited from table public.parent: "UUID" uuid NOT NULL DEFAULT gen_random_uuid(),
-- Inherited from table public.parent: "parentField" text COLLATE pg_catalog."default" DEFAULT 'child'::text,
-- Inherited from table public.parent: "entryType" integer NOT NULL DEFAULT 1,
"childField" text COLLATE pg_catalog."default" DEFAULT 'child'::text,
CONSTRAINT child_pkey PRIMARY KEY ("UUID")
)
INHERITS (public.parent)
TABLESPACE pg_default;
<<<<< generated by pgadmin
As you can see:
The additional CONSTRAINT PRIMARY KEY for column "UUID" will be created by the script.
The changed default values for the inherited columns "parentField" and "entryType" are only mentioned in the comments, but the needed "ALTER"-statements aren't there.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status