\pset null _null_ \pset format unaligned SET client_min_messages = warning; SET ROLE postgres; CREATE TABLE measurement ( city_id int not null, logdate date not null, peaktemp int, unitsales int ) PARTITION BY RANGE (logdate); CREATE TABLE measurement_y2006m02 PARTITION OF measurement FOR VALUES FROM ('2006-02-01') TO ('2006-03-01'); CREATE TABLE measurement_y2006m03 PARTITION OF measurement FOR VALUES FROM ('2006-03-01') TO ('2006-04-01'); CREATE INDEX ON measurement_y2006m02 (logdate); CREATE INDEX ON measurement_y2006m03 (logdate); select ddlx_script('measurement'); ddlx_script BEGIN; /* DROP TABLE measurement; */ -- Type: TABLE ; Name: measurement; Owner: postgres CREATE TABLE measurement ( city_id integer NOT NULL, logdate date NOT NULL, peaktemp integer, unitsales integer ) PARTITION BY RANGE (logdate); COMMENT ON TABLE measurement IS NULL; ALTER TABLE measurement OWNER TO postgres; END; (1 row) ------ CREATE TABLE customers(cust_id bigint NOT NULL,cust_name varchar(32) NOT NULL,cust_address text, cust_country text) PARTITION BY LIST(cust_country); CREATE TABLE customer_ind PARTITION OF customers FOR VALUES IN ('ind'); CREATE TABLE customer_jap PARTITION OF customers FOR VALUES IN ('jap'); INSERT INTO customers VALUES (2039,'Puja','Hyderabad','ind'); SELECT tableoid::regclass,* FROM customers; tableoid|cust_id|cust_name|cust_address|cust_country customer_ind|2039|Puja|Hyderabad|ind (1 row) SELECT * FROM customer_ind; cust_id|cust_name|cust_address|cust_country 2039|Puja|Hyderabad|ind (1 row) UPDATE customers SET cust_country ='jap' WHERE cust_id=2039; ERROR: new row for relation "customer_ind" violates partition constraint DETAIL: Failing row contains (2039, Puja, Hyderabad, jap). SELECT * FROM customer_jap; cust_id|cust_name|cust_address|cust_country (0 rows) select ddlx_script('customers'); ddlx_script BEGIN; /* DROP TABLE customers; */ -- Type: TABLE ; Name: customers; Owner: postgres CREATE TABLE customers ( cust_id bigint NOT NULL, cust_name character varying(32) NOT NULL, cust_address text, cust_country text ) PARTITION BY LIST (cust_country); COMMENT ON TABLE customers IS NULL; ALTER TABLE customers OWNER TO postgres; END; (1 row) select ddlx_script('customer_jap'); ddlx_script BEGIN; /* DROP TABLE customer_jap; */ -- Type: TABLE ; Name: customer_jap; Owner: postgres CREATE TABLE customer_jap PARTITION OF customers FOR VALUES IN ('jap'); COMMENT ON TABLE customer_jap IS NULL; ALTER TABLE customer_jap OWNER TO postgres; END; (1 row) -- statistics CREATE TABLE test_stat ( a int primary key, b int ); CREATE STATISTICS test_stat1 (dependencies) ON a, b FROM test_stat; \x select ddlx_create(oid),ddlx_drop(oid) from pg_statistic_ext where stxname='test_stat1'; ddlx_create|CREATE STATISTICS public.test_stat1 (dependencies) ON a, b FROM test_stat; ALTER STATISTICS test_stat1 OWNER TO postgres; ddlx_drop|DROP STATISTICS test_stat1; \x select ddlx_script('test_stat'); ddlx_script BEGIN; /* DROP TABLE test_stat; */ -- Type: TABLE ; Name: test_stat; Owner: postgres CREATE TABLE test_stat ( a integer NOT NULL, b integer ); COMMENT ON TABLE test_stat IS NULL; ALTER TABLE test_stat ADD CONSTRAINT test_stat_pkey PRIMARY KEY (a); CREATE STATISTICS public.test_stat1 (dependencies) ON a, b FROM test_stat; ALTER STATISTICS test_stat1 OWNER TO postgres; ALTER TABLE test_stat OWNER TO postgres; END; (1 row)