drop extension cube cascade;
NOTICE: drop cascades to table foo column f1
\d foo
- Table "public.foo"
- Column | Type | Modifiers
---------+---------+-----------
- f2 | integer |
+ Table "public.foo"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ f2 | integer | | |
-- list what's installed
\dT public.*
(5 rows)
\d import_dest1.*
- Foreign table "import_dest1.t1"
- Column | Type | Modifiers | FDW Options
---------+-------------------+-----------+--------------------
- c1 | integer | | (column_name 'c1')
- c2 | character varying | not null | (column_name 'c2')
+ Foreign table "import_dest1.t1"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | | (column_name 'c1')
+ c2 | character varying | | not null | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't1')
- Foreign table "import_dest1.t2"
- Column | Type | Modifiers | FDW Options
---------+-------------------+---------------+--------------------
- c1 | integer | | (column_name 'c1')
- c2 | character varying | | (column_name 'c2')
- c3 | text | collate POSIX | (column_name 'c3')
+ Foreign table "import_dest1.t2"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | | (column_name 'c1')
+ c2 | character varying | | | | (column_name 'c2')
+ c3 | text | POSIX | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't2')
- Foreign table "import_dest1.t3"
- Column | Type | Modifiers | FDW Options
---------+--------------------------+-----------+--------------------
- c1 | timestamp with time zone | | (column_name 'c1')
- c2 | typ1 | | (column_name 'c2')
+ Foreign table "import_dest1.t3"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+--------------------------+-----------+----------+---------+--------------------
+ c1 | timestamp with time zone | | | | (column_name 'c1')
+ c2 | typ1 | | | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't3')
- Foreign table "import_dest1.x 4"
- Column | Type | Modifiers | FDW Options
---------+-----------------------+-----------+---------------------
- c1 | double precision | | (column_name 'c1')
- C 2 | text | | (column_name 'C 2')
- c3 | character varying(42) | | (column_name 'c3')
+ Foreign table "import_dest1.x 4"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-----------------------+-----------+----------+---------+---------------------
+ c1 | double precision | | | | (column_name 'c1')
+ C 2 | text | | | | (column_name 'C 2')
+ c3 | character varying(42) | | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 4')
- Foreign table "import_dest1.x 5"
- Column | Type | Modifiers | FDW Options
---------+------+-----------+-------------
+ Foreign table "import_dest1.x 5"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+------+-----------+----------+---------+-------------
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 5')
(5 rows)
\d import_dest2.*
- Foreign table "import_dest2.t1"
- Column | Type | Modifiers | FDW Options
---------+-------------------+-----------+--------------------
- c1 | integer | | (column_name 'c1')
- c2 | character varying | not null | (column_name 'c2')
+ Foreign table "import_dest2.t1"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | | (column_name 'c1')
+ c2 | character varying | | not null | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't1')
- Foreign table "import_dest2.t2"
- Column | Type | Modifiers | FDW Options
---------+-------------------+---------------+--------------------
- c1 | integer | default 42 | (column_name 'c1')
- c2 | character varying | | (column_name 'c2')
- c3 | text | collate POSIX | (column_name 'c3')
+ Foreign table "import_dest2.t2"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | 42 | (column_name 'c1')
+ c2 | character varying | | | | (column_name 'c2')
+ c3 | text | POSIX | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't2')
- Foreign table "import_dest2.t3"
- Column | Type | Modifiers | FDW Options
---------+--------------------------+---------------+--------------------
- c1 | timestamp with time zone | default now() | (column_name 'c1')
- c2 | typ1 | | (column_name 'c2')
+ Foreign table "import_dest2.t3"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+--------------------------+-----------+----------+---------+--------------------
+ c1 | timestamp with time zone | | | now() | (column_name 'c1')
+ c2 | typ1 | | | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't3')
- Foreign table "import_dest2.x 4"
- Column | Type | Modifiers | FDW Options
---------+-----------------------+-----------+---------------------
- c1 | double precision | | (column_name 'c1')
- C 2 | text | | (column_name 'C 2')
- c3 | character varying(42) | | (column_name 'c3')
+ Foreign table "import_dest2.x 4"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-----------------------+-----------+----------+---------+---------------------
+ c1 | double precision | | | | (column_name 'c1')
+ C 2 | text | | | | (column_name 'C 2')
+ c3 | character varying(42) | | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 4')
- Foreign table "import_dest2.x 5"
- Column | Type | Modifiers | FDW Options
---------+------+-----------+-------------
+ Foreign table "import_dest2.x 5"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+------+-----------+----------+---------+-------------
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 5')
(5 rows)
\d import_dest3.*
- Foreign table "import_dest3.t1"
- Column | Type | Modifiers | FDW Options
---------+-------------------+-----------+--------------------
- c1 | integer | | (column_name 'c1')
- c2 | character varying | | (column_name 'c2')
+ Foreign table "import_dest3.t1"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | | (column_name 'c1')
+ c2 | character varying | | | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't1')
- Foreign table "import_dest3.t2"
- Column | Type | Modifiers | FDW Options
---------+-------------------+-----------+--------------------
- c1 | integer | | (column_name 'c1')
- c2 | character varying | | (column_name 'c2')
- c3 | text | | (column_name 'c3')
+ Foreign table "import_dest3.t2"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-------------------+-----------+----------+---------+--------------------
+ c1 | integer | | | | (column_name 'c1')
+ c2 | character varying | | | | (column_name 'c2')
+ c3 | text | | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't2')
- Foreign table "import_dest3.t3"
- Column | Type | Modifiers | FDW Options
---------+--------------------------+-----------+--------------------
- c1 | timestamp with time zone | | (column_name 'c1')
- c2 | typ1 | | (column_name 'c2')
+ Foreign table "import_dest3.t3"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+--------------------------+-----------+----------+---------+--------------------
+ c1 | timestamp with time zone | | | | (column_name 'c1')
+ c2 | typ1 | | | | (column_name 'c2')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 't3')
- Foreign table "import_dest3.x 4"
- Column | Type | Modifiers | FDW Options
---------+-----------------------+-----------+---------------------
- c1 | double precision | | (column_name 'c1')
- C 2 | text | | (column_name 'C 2')
- c3 | character varying(42) | | (column_name 'c3')
+ Foreign table "import_dest3.x 4"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+-----------------------+-----------+----------+---------+---------------------
+ c1 | double precision | | | | (column_name 'c1')
+ C 2 | text | | | | (column_name 'C 2')
+ c3 | character varying(42) | | | | (column_name 'c3')
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 4')
- Foreign table "import_dest3.x 5"
- Column | Type | Modifiers | FDW Options
---------+------+-----------+-------------
+ Foreign table "import_dest3.x 5"
+ Column | Type | Collation | Nullable | Default | FDW Options
+--------+------+-----------+----------+---------+-------------
Server: loopback
FDW Options: (schema_name 'import_source', table_name 'x 5')
WITH (user_catalog_table = true)
;
\d+ replication_metadata
- Table "public.replication_metadata"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-------------------------------------------------------------------+----------+--------------+-------------
- id | integer | not null default nextval('replication_metadata_id_seq'::regclass) | plain | |
- relation | name | not null | plain | |
- options | text[] | | extended | |
+ Table "public.replication_metadata"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+-------------
+ id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | |
+ relation | name | | not null | | plain | |
+ options | text[] | | | | extended | |
Indexes:
"replication_metadata_pkey" PRIMARY KEY, btree (id)
Options: user_catalog_table=true
VALUES ('foo', ARRAY['a', 'b']);
ALTER TABLE replication_metadata RESET (user_catalog_table);
\d+ replication_metadata
- Table "public.replication_metadata"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-------------------------------------------------------------------+----------+--------------+-------------
- id | integer | not null default nextval('replication_metadata_id_seq'::regclass) | plain | |
- relation | name | not null | plain | |
- options | text[] | | extended | |
+ Table "public.replication_metadata"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+-------------
+ id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | |
+ relation | name | | not null | | plain | |
+ options | text[] | | | | extended | |
Indexes:
"replication_metadata_pkey" PRIMARY KEY, btree (id)
VALUES ('bar', ARRAY['a', 'b']);
ALTER TABLE replication_metadata SET (user_catalog_table = true);
\d+ replication_metadata
- Table "public.replication_metadata"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-------------------------------------------------------------------+----------+--------------+-------------
- id | integer | not null default nextval('replication_metadata_id_seq'::regclass) | plain | |
- relation | name | not null | plain | |
- options | text[] | | extended | |
+ Table "public.replication_metadata"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+-------------
+ id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | |
+ relation | name | | not null | | plain | |
+ options | text[] | | | | extended | |
Indexes:
"replication_metadata_pkey" PRIMARY KEY, btree (id)
Options: user_catalog_table=true
ERROR: cannot rewrite table "replication_metadata" used as a catalog table
ALTER TABLE replication_metadata SET (user_catalog_table = false);
\d+ replication_metadata
- Table "public.replication_metadata"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------------+---------+-------------------------------------------------------------------+----------+--------------+-------------
- id | integer | not null default nextval('replication_metadata_id_seq'::regclass) | plain | |
- relation | name | not null | plain | |
- options | text[] | | extended | |
- rewritemeornot | integer | | plain | |
+ Table "public.replication_metadata"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------------+---------+-----------+----------+--------------------------------------------------+----------+--------------+-------------
+ id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | |
+ relation | name | | not null | | plain | |
+ options | text[] | | | | extended | |
+ rewritemeornot | integer | | | | plain | |
Indexes:
"replication_metadata_pkey" PRIMARY KEY, btree (id)
Options: user_catalog_table=false
<programlisting>
postgres=# \d tab
Table "public.tab"
- Column | Type | Modifiers
---------+---------+-----------
- col | integer |
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ col | integer | | |
Indexes:
"idx" btree (col) INVALID
</programlisting>
Now look at the table definition again:
<programlisting>
testdb=> <userinput>\d my_table</userinput>
- Table "my_table"
- Attribute | Type | Modifier
------------+---------+--------------------
- first | integer | not null default 0
- second | text |
-
+ Table "public.my_table"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ first | integer | | not null | 0
+ second | text | | |
</programlisting>
Now we change the prompt to something more interesting:
<programlisting>
bool printTableInitialized = false;
int i;
char *view_def = NULL;
- char *headers[9];
+ char *headers[11];
char **seq_values = NULL;
- char **modifiers = NULL;
char **ptr;
PQExpBufferData title;
PQExpBufferData tmpbuf;
char relpersistence;
char relreplident;
} tableinfo;
- bool show_modifiers = false;
+ bool show_column_details = false;
bool retval;
retval = false;
tableinfo.relkind == 'm' ||
tableinfo.relkind == 'f' || tableinfo.relkind == 'c')
{
- show_modifiers = true;
- headers[cols++] = gettext_noop("Modifiers");
- modifiers = pg_malloc0((numrows + 1) * sizeof(*modifiers));
+ headers[cols++] = gettext_noop("Collation");
+ headers[cols++] = gettext_noop("Nullable");
+ headers[cols++] = gettext_noop("Default");
+ show_column_details = true;
}
if (tableinfo.relkind == 'S')
/* Type */
printTableAddCell(&cont, PQgetvalue(res, i, 1), false, false);
- /* Modifiers: collate, not null, default */
- if (show_modifiers)
+ /* Collation, Nullable, Default */
+ if (show_column_details)
{
- resetPQExpBuffer(&tmpbuf);
+ printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
- if (!PQgetisnull(res, i, 5))
- {
- if (tmpbuf.len > 0)
- appendPQExpBufferChar(&tmpbuf, ' ');
- appendPQExpBuffer(&tmpbuf, _("collate %s"),
- PQgetvalue(res, i, 5));
- }
+ printTableAddCell(&cont, strcmp(PQgetvalue(res, i, 3), "t") == 0 ? "not null" : "", false, false);
- if (strcmp(PQgetvalue(res, i, 3), "t") == 0)
- {
- if (tmpbuf.len > 0)
- appendPQExpBufferChar(&tmpbuf, ' ');
- appendPQExpBufferStr(&tmpbuf, _("not null"));
- }
-
- /* handle "default" here */
/* (note: above we cut off the 'default' string at 128) */
- if (strlen(PQgetvalue(res, i, 2)) != 0)
- {
- if (tmpbuf.len > 0)
- appendPQExpBufferChar(&tmpbuf, ' ');
- /* translator: default values of column definitions */
- appendPQExpBuffer(&tmpbuf, _("default %s"),
- PQgetvalue(res, i, 2));
- }
-
- modifiers[i] = pg_strdup(tmpbuf.data);
- printTableAddCell(&cont, modifiers[i], false, false);
+ printTableAddCell(&cont, PQgetvalue(res, i, 2), false, false);
}
/* Value: for sequences only */
free(seq_values);
}
- if (modifiers)
- {
- for (ptr = modifiers; *ptr; ptr++)
- free(*ptr);
- free(modifiers);
- }
-
if (view_def)
free(view_def);
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
- " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n"
- " TRIM(LEADING\n",
+ " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Type"));
if (pset.sversion >= 90100)
- appendPQExpBufferStr(&buf,
- " COALESCE((SELECT ' collate ' || c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
- " WHERE c.oid = t.typcollation AND bt.oid = t.typbasetype AND t.typcollation <> bt.typcollation), '') ||\n");
+ appendPQExpBuffer(&buf,
+ " (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type bt\n"
+ " WHERE c.oid = t.typcollation AND bt.oid = t.typbasetype AND t.typcollation <> bt.typcollation) as \"%s\",\n",
+ gettext_noop("Collation"));
appendPQExpBuffer(&buf,
- " CASE WHEN t.typnotnull THEN ' not null' ELSE '' END ||\n"
- " CASE WHEN t.typdefault IS NOT NULL THEN ' default ' || t.typdefault ELSE '' END\n"
- " ) as \"%s\",\n"
+ " CASE WHEN t.typnotnull THEN 'not null' END as \"%s\",\n"
+ " t.typdefault as \"%s\",\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid = r.contypid\n"
" ), ' ') as \"%s\"",
- gettext_noop("Modifier"),
+ gettext_noop("Nullable"),
+ gettext_noop("Default"),
gettext_noop("Check"));
if (verbose)
/*
Table "public.history"
- Column | Type | Modifiers
---------------+-----------------------------+-----------
+ Column | Type | Nullable
+--------------+-----------------------------+----------
customerid | integer | not null
timestamp | timestamp without time zone | not null
action_taken | character(5) | not null
/*
Table "public.history"
- Column | Type | Modifiers
---------------+-----------------------------+-----------
+ Column | Type | Nullable
+--------------+-----------------------------+----------
customerid | integer | not null
timestamp | timestamp without time zone | not null
action_taken | character(5) | not null
-- renaming constraints vs. inheritance
CREATE TABLE constraint_rename_test (a int CONSTRAINT con1 CHECK (a > 0), b int, c int);
\d constraint_rename_test
-Table "public.constraint_rename_test"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
+ Table "public.constraint_rename_test"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
Check constraints:
"con1" CHECK (a > 0)
NOTICE: merging column "a" with inherited definition
NOTICE: merging constraint "con1" with inherited definition
\d constraint_rename_test2
-Table "public.constraint_rename_test2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
- d | integer |
+ Table "public.constraint_rename_test2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
+ d | integer | | |
Check constraints:
"con1" CHECK (a > 0)
Inherits: constraint_rename_test
ERROR: inherited constraint "con1" must be renamed in child tables too
ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo; -- ok
\d constraint_rename_test
-Table "public.constraint_rename_test"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
+ Table "public.constraint_rename_test"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
Check constraints:
"con1foo" CHECK (a > 0)
Number of child tables: 1 (Use \d+ to list them.)
\d constraint_rename_test2
-Table "public.constraint_rename_test2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
- d | integer |
+ Table "public.constraint_rename_test2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
+ d | integer | | |
Check constraints:
"con1foo" CHECK (a > 0)
Inherits: constraint_rename_test
ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo; -- ok
ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar; -- ok
\d constraint_rename_test
-Table "public.constraint_rename_test"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
+ Table "public.constraint_rename_test"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
Check constraints:
"con1foo" CHECK (a > 0)
"con2bar" CHECK (b > 0) NO INHERIT
Number of child tables: 1 (Use \d+ to list them.)
\d constraint_rename_test2
-Table "public.constraint_rename_test2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
- d | integer |
+ Table "public.constraint_rename_test2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
+ d | integer | | |
Check constraints:
"con1foo" CHECK (a > 0)
Inherits: constraint_rename_test
ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a);
ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo; -- ok
\d constraint_rename_test
-Table "public.constraint_rename_test"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer | not null
- b | integer |
- c | integer |
+ Table "public.constraint_rename_test"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | not null |
+ b | integer | | |
+ c | integer | | |
Indexes:
"con3foo" PRIMARY KEY, btree (a)
Check constraints:
Number of child tables: 1 (Use \d+ to list them.)
\d constraint_rename_test2
-Table "public.constraint_rename_test2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
- c | integer |
- d | integer |
+ Table "public.constraint_rename_test2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
+ c | integer | | |
+ d | integer | | |
Check constraints:
"con1foo" CHECK (a > 0)
Inherits: constraint_rename_test
create table nv_parent (d date, check (false) no inherit not valid);
-- not valid constraint added at creation time should automatically become valid
\d nv_parent
- Table "public.nv_parent"
- Column | Type | Modifiers
---------+------+-----------
- d | date |
+ Table "public.nv_parent"
+ Column | Type | Collation | Nullable | Default
+--------+------+-----------+----------+---------
+ d | date | | |
Check constraints:
"nv_parent_check" CHECK (false) NO INHERIT
-- add an inherited NOT VALID constraint
alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31'::date) not valid;
\d nv_child_2009
-Table "public.nv_child_2009"
- Column | Type | Modifiers
---------+------+-----------
- d | date |
+ Table "public.nv_child_2009"
+ Column | Type | Collation | Nullable | Default
+--------+------+-----------+----------+---------
+ d | date | | |
Check constraints:
"nv_child_2009_d_check" CHECK (d >= '01-01-2009'::date AND d <= '12-31-2009'::date)
"nv_parent_d_check" CHECK (d >= '01-01-2001'::date AND d <= '12-31-2099'::date) NOT VALID
CREATE TABLE test_inh_check (a float check (a > 10.2), b float);
CREATE TABLE test_inh_check_child() INHERITS(test_inh_check);
\d test_inh_check
- Table "public.test_inh_check"
- Column | Type | Modifiers
---------+------------------+-----------
- a | double precision |
- b | double precision |
+ Table "public.test_inh_check"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | double precision | | |
+ b | double precision | | |
Check constraints:
"test_inh_check_a_check" CHECK (a > 10.2::double precision)
Number of child tables: 1 (Use \d+ to list them.)
\d test_inh_check_child
- Table "public.test_inh_check_child"
- Column | Type | Modifiers
---------+------------------+-----------
- a | double precision |
- b | double precision |
+ Table "public.test_inh_check_child"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | double precision | | |
+ b | double precision | | |
Check constraints:
"test_inh_check_a_check" CHECK (a > 10.2::double precision)
Inherits: test_inh_check
ALTER TABLE test_inh_check ALTER COLUMN a TYPE numeric;
\d test_inh_check
- Table "public.test_inh_check"
- Column | Type | Modifiers
---------+------------------+-----------
- a | numeric |
- b | double precision |
+ Table "public.test_inh_check"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | numeric | | |
+ b | double precision | | |
Check constraints:
"test_inh_check_a_check" CHECK (a::double precision > 10.2::double precision)
Number of child tables: 1 (Use \d+ to list them.)
\d test_inh_check_child
- Table "public.test_inh_check_child"
- Column | Type | Modifiers
---------+------------------+-----------
- a | numeric |
- b | double precision |
+ Table "public.test_inh_check_child"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | numeric | | |
+ b | double precision | | |
Check constraints:
"test_inh_check_a_check" CHECK (a::double precision > 10.2::double precision)
Inherits: test_inh_check
ALTER TABLE test_inh_check ADD CONSTRAINT bmerged CHECK (b > 1);
NOTICE: merging constraint "bmerged" with inherited definition
\d test_inh_check
- Table "public.test_inh_check"
- Column | Type | Modifiers
---------+------------------+-----------
- a | numeric |
- b | double precision |
+ Table "public.test_inh_check"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | numeric | | |
+ b | double precision | | |
Check constraints:
"bmerged" CHECK (b > 1::double precision)
"bnoinherit" CHECK (b > 100::double precision) NO INHERIT
Number of child tables: 1 (Use \d+ to list them.)
\d test_inh_check_child
- Table "public.test_inh_check_child"
- Column | Type | Modifiers
---------+------------------+-----------
- a | numeric |
- b | double precision |
+ Table "public.test_inh_check_child"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ a | numeric | | |
+ b | double precision | | |
Check constraints:
"blocal" CHECK (b < 1000::double precision)
"bmerged" CHECK (b > 1::double precision)
ALTER TABLE test_inh_check ALTER COLUMN b TYPE numeric;
NOTICE: merging constraint "bmerged" with inherited definition
\d test_inh_check
-Table "public.test_inh_check"
- Column | Type | Modifiers
---------+---------+-----------
- a | numeric |
- b | numeric |
+ Table "public.test_inh_check"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | numeric | | |
+ b | numeric | | |
Check constraints:
"bmerged" CHECK (b::double precision > 1::double precision)
"bnoinherit" CHECK (b::double precision > 100::double precision) NO INHERIT
Number of child tables: 1 (Use \d+ to list them.)
\d test_inh_check_child
-Table "public.test_inh_check_child"
- Column | Type | Modifiers
---------+---------+-----------
- a | numeric |
- b | numeric |
+ Table "public.test_inh_check_child"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | numeric | | |
+ b | numeric | | |
Check constraints:
"blocal" CHECK (b::double precision < 1000::double precision)
"bmerged" CHECK (b::double precision > 1::double precision)
ANALYZE check_fk_presence_2;
ROLLBACK;
\d check_fk_presence_2
-Table "public.check_fk_presence_2"
- Column | Type | Modifiers
---------+---------+-----------
- id | integer |
- t | text |
+ Table "public.check_fk_presence_2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ id | integer | | |
+ t | text | | |
Foreign-key constraints:
"check_fk_presence_2_id_fkey" FOREIGN KEY (id) REFERENCES check_fk_presence_1(id)
--
CREATE TYPE test_type AS (a int);
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
ALTER TYPE nosuchtype ADD ATTRIBUTE b text; -- fails
ERROR: relation "nosuchtype" does not exist
ALTER TYPE test_type ADD ATTRIBUTE b text;
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | text |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | | |
ALTER TYPE test_type ADD ATTRIBUTE b text; -- fails
ERROR: column "b" of relation "test_type" already exists
ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE varchar;
\d test_type
- Composite type "public.test_type"
- Column | Type | Modifiers
---------+-------------------+-----------
- a | integer |
- b | character varying |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+-------------------+-----------+----------+---------
+ a | integer | | |
+ b | character varying | | |
ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE integer;
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
ALTER TYPE test_type DROP ATTRIBUTE b;
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
ALTER TYPE test_type DROP ATTRIBUTE c; -- fails
ERROR: column "c" of relation "test_type" does not exist
NOTICE: column "c" of relation "test_type" does not exist, skipping
ALTER TYPE test_type DROP ATTRIBUTE a, ADD ATTRIBUTE d boolean;
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- d | boolean |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ d | boolean | | |
ALTER TYPE test_type RENAME ATTRIBUTE a TO aa;
ERROR: column "a" does not exist
ALTER TYPE test_type RENAME ATTRIBUTE d TO dd;
\d test_type
-Composite type "public.test_type"
- Column | Type | Modifiers
---------+---------+-----------
- dd | boolean |
+ Composite type "public.test_type"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ dd | boolean | | |
DROP TYPE test_type;
CREATE TYPE test_type1 AS (a int, b text);
CREATE TABLE test_tbl2 OF test_type2;
CREATE TABLE test_tbl2_subclass () INHERITS (test_tbl2);
\d test_type2
-Composite type "public.test_type2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | text |
+ Composite type "public.test_type2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | | |
\d test_tbl2
- Table "public.test_tbl2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | text |
+ Table "public.test_tbl2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | | |
Number of child tables: 1 (Use \d+ to list them.)
Typed table of type: test_type2
HINT: Use ALTER ... CASCADE to alter the typed tables too.
ALTER TYPE test_type2 ADD ATTRIBUTE c text CASCADE;
\d test_type2
-Composite type "public.test_type2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | text |
- c | text |
+ Composite type "public.test_type2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | | |
+ c | text | | |
\d test_tbl2
- Table "public.test_tbl2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | text |
- c | text |
+ Table "public.test_tbl2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | | |
+ c | text | | |
Number of child tables: 1 (Use \d+ to list them.)
Typed table of type: test_type2
HINT: Use ALTER ... CASCADE to alter the typed tables too.
ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar CASCADE;
\d test_type2
- Composite type "public.test_type2"
- Column | Type | Modifiers
---------+-------------------+-----------
- a | integer |
- b | character varying |
- c | text |
+ Composite type "public.test_type2"
+ Column | Type | Collation | Nullable | Default
+--------+-------------------+-----------+----------+---------
+ a | integer | | |
+ b | character varying | | |
+ c | text | | |
\d test_tbl2
- Table "public.test_tbl2"
- Column | Type | Modifiers
---------+-------------------+-----------
- a | integer |
- b | character varying |
- c | text |
+ Table "public.test_tbl2"
+ Column | Type | Collation | Nullable | Default
+--------+-------------------+-----------+----------+---------
+ a | integer | | |
+ b | character varying | | |
+ c | text | | |
Number of child tables: 1 (Use \d+ to list them.)
Typed table of type: test_type2
HINT: Use ALTER ... CASCADE to alter the typed tables too.
ALTER TYPE test_type2 DROP ATTRIBUTE b CASCADE;
\d test_type2
-Composite type "public.test_type2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- c | text |
+ Composite type "public.test_type2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ c | text | | |
\d test_tbl2
- Table "public.test_tbl2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- c | text |
+ Table "public.test_tbl2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ c | text | | |
Number of child tables: 1 (Use \d+ to list them.)
Typed table of type: test_type2
HINT: Use ALTER ... CASCADE to alter the typed tables too.
ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa CASCADE;
\d test_type2
-Composite type "public.test_type2"
- Column | Type | Modifiers
---------+---------+-----------
- aa | integer |
- c | text |
+ Composite type "public.test_type2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ aa | integer | | |
+ c | text | | |
\d test_tbl2
- Table "public.test_tbl2"
- Column | Type | Modifiers
---------+---------+-----------
- aa | integer |
- c | text |
+ Table "public.test_tbl2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ aa | integer | | |
+ c | text | | |
Number of child tables: 1 (Use \d+ to list them.)
Typed table of type: test_type2
\d test_tbl2_subclass
-Table "public.test_tbl2_subclass"
- Column | Type | Modifiers
---------+---------+-----------
- aa | integer |
- c | text |
+ Table "public.test_tbl2_subclass"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ aa | integer | | |
+ c | text | | |
Inherits: test_tbl2
DROP TABLE test_tbl2_subclass;
ALTER TABLE tt7 OF tt_t1; -- reassign an already-typed table
ALTER TABLE tt7 NOT OF;
\d tt7
- Table "public.tt7"
- Column | Type | Modifiers
---------+--------------+-----------
- x | integer |
- y | numeric(8,2) |
+ Table "public.tt7"
+ Column | Type | Collation | Nullable | Default
+--------+--------------+-----------+----------+---------
+ x | integer | | |
+ y | numeric(8,2) | | |
-- make sure we can drop a constraint on the parent but it remains on the child
CREATE TABLE test_drop_constr_parent (c text CHECK (c IS NOT NULL));
ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1;
ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2;
\d alter2.tt8
- Table "alter2.tt8"
- Column | Type | Modifiers
---------+---------+--------------------
- a | integer |
- f1 | integer | not null default 0
+ Table "alter2.tt8"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ f1 | integer | | not null | 0
Indexes:
"xxx" PRIMARY KEY, btree (f1)
Check constraints:
-- test ADD COLUMN IF NOT EXISTS
CREATE TABLE test_add_column(c1 integer);
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN c2 integer;
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN c2 integer; -- fail because c2 already exists
ERROR: column "c2" of relation "test_add_column" already exists
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c2 integer; -- skipping because c2 already exists
NOTICE: column "c2" of relation "test_add_column" already exists, skipping
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN c2 integer, -- fail because c2 already exists
ADD COLUMN c3 integer;
ERROR: column "c2" of relation "test_add_column" already exists
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists
ADD COLUMN c3 integer; -- fail because c3 already exists
NOTICE: column "c2" of relation "test_add_column" already exists, skipping
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
- c3 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
+ c3 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists
NOTICE: column "c2" of relation "test_add_column" already exists, skipping
NOTICE: column "c3" of relation "test_add_column" already exists, skipping
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
- c3 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
+ c3 | integer | | |
ALTER TABLE test_add_column
ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists
NOTICE: column "c2" of relation "test_add_column" already exists, skipping
NOTICE: column "c3" of relation "test_add_column" already exists, skipping
\d test_add_column
-Table "public.test_add_column"
- Column | Type | Modifiers
---------+---------+-----------
- c1 | integer |
- c2 | integer |
- c3 | integer |
- c4 | integer |
+ Table "public.test_add_column"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ c1 | integer | | |
+ c2 | integer | | |
+ c3 | integer | | |
+ c4 | integer | | |
DROP TABLE test_add_column;
b text COLLATE "en_US" NOT NULL
);
\d collate_test1
- Table "public.collate_test1"
- Column | Type | Modifiers
---------+---------+------------------------
- a | integer |
- b | text | collate en_US not null
+ Table "public.collate_test1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | en_US | not null |
CREATE TABLE collate_test_fail (
a int,
LIKE collate_test1
);
\d collate_test_like
- Table "public.collate_test_like"
- Column | Type | Modifiers
---------+---------+------------------------
- a | integer |
- b | text | collate en_US not null
+ Table "public.collate_test_like"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | en_US | not null |
CREATE TABLE collate_test2 (
a int,
drop cascades to view collate_dep_test3
drop cascades to index collate_dep_test4i
\d collate_dep_test1
-Table "public.collate_dep_test1"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
+ Table "public.collate_dep_test1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
\d collate_dep_test2
-Composite type "public.collate_dep_test2"
- Column | Type | Modifiers
---------+---------+-----------
- x | integer |
+ Composite type "public.collate_dep_test2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ x | integer | | |
DROP TABLE collate_dep_test1, collate_dep_test4t;
DROP TYPE collate_dep_test2;
b text COLLATE "C" NOT NULL
);
\d collate_test1
- Table "collate_tests.collate_test1"
- Column | Type | Modifiers
---------+---------+--------------------
- a | integer |
- b | text | collate C not null
+ Table "collate_tests.collate_test1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | C | not null |
CREATE TABLE collate_test_fail (
a int COLLATE "C",
LIKE collate_test1
);
\d collate_test_like
-Table "collate_tests.collate_test_like"
- Column | Type | Modifiers
---------+---------+--------------------
- a | integer |
- b | text | collate C not null
+ Table "collate_tests.collate_test_like"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | text | C | not null |
CREATE TABLE collate_test2 (
a int,
end $$ language plpgsql immutable;
alter table check_con_tbl add check (check_con_function(check_con_tbl.*));
\d+ check_con_tbl
- Table "public.check_con_tbl"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- f1 | integer | | plain | |
+ Table "public.check_con_tbl"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ f1 | integer | | | | plain | |
Check constraints:
"check_con_tbl_check" CHECK (check_con_function(check_con_tbl.*))
DELETE FROM concur_heap WHERE f1 = 'b';
VACUUM FULL concur_heap;
\d concur_heap
-Table "public.concur_heap"
- Column | Type | Modifiers
---------+------+-----------
- f1 | text |
- f2 | text |
+ Table "public.concur_heap"
+ Column | Type | Collation | Nullable | Default
+--------+------+-----------+----------+---------
+ f1 | text | | |
+ f2 | text | | |
Indexes:
"concur_index2" UNIQUE, btree (f1)
"concur_index3" UNIQUE, btree (f2) INVALID
REINDEX TABLE concur_heap;
\d concur_heap
-Table "public.concur_heap"
- Column | Type | Modifiers
---------+------+-----------
- f1 | text |
- f2 | text |
+ Table "public.concur_heap"
+ Column | Type | Collation | Nullable | Default
+--------+------+-----------+----------+---------
+ f1 | text | | |
+ f2 | text | | |
Indexes:
"concur_index2" UNIQUE, btree (f1)
"concur_index3" UNIQUE, btree (f2)
DROP INDEX CONCURRENTLY "concur_index1";
DROP INDEX CONCURRENTLY "concur_heap_expr_idx";
\d concur_heap
-Table "public.concur_heap"
- Column | Type | Modifiers
---------+------+-----------
- f1 | text |
- f2 | text |
+ Table "public.concur_heap"
+ Column | Type | Collation | Nullable | Default
+--------+------+-----------+----------+---------
+ f1 | text | | |
+ f2 | text | | |
Indexes:
"std_index" btree (f2)
CREATE UNIQUE INDEX cwi_uniq_idx ON cwi_test(a , b);
ALTER TABLE cwi_test ADD primary key USING INDEX cwi_uniq_idx;
\d cwi_test
- Table "public.cwi_test"
- Column | Type | Modifiers
---------+-----------------------+-----------
- a | integer | not null
- b | character varying(10) | not null
- c | character(1) |
+ Table "public.cwi_test"
+ Column | Type | Collation | Nullable | Default
+--------+-----------------------+-----------+----------+---------
+ a | integer | | not null |
+ b | character varying(10) | | not null |
+ c | character(1) | | |
Indexes:
"cwi_uniq_idx" PRIMARY KEY, btree (a, b)
USING INDEX cwi_uniq2_idx;
NOTICE: ALTER TABLE / ADD CONSTRAINT USING INDEX will rename index "cwi_uniq2_idx" to "cwi_replaced_pkey"
\d cwi_test
- Table "public.cwi_test"
- Column | Type | Modifiers
---------+-----------------------+-----------
- a | integer | not null
- b | character varying(10) | not null
- c | character(1) |
+ Table "public.cwi_test"
+ Column | Type | Collation | Nullable | Default
+--------+-----------------------+-----------+----------+---------
+ a | integer | | not null |
+ b | character varying(10) | | not null |
+ c | character(1) | | |
Indexes:
"cwi_replaced_pkey" PRIMARY KEY, btree (b, a)
ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE EXTERNAL;
CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE);
\d+ ctlt12_storage
- Table "public.ctlt12_storage"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | main | |
- b | text | | extended | |
- c | text | | external | |
+ Table "public.ctlt12_storage"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | main | |
+ b | text | | | | extended | |
+ c | text | | | | external | |
CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
\d+ ctlt12_comments
- Table "public.ctlt12_comments"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | extended | | A
- b | text | | extended | | B
- c | text | | extended | | C
+ Table "public.ctlt12_comments"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | extended | | A
+ b | text | | | | extended | | B
+ c | text | | | | extended | | C
CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
NOTICE: merging column "a" with inherited definition
NOTICE: merging column "b" with inherited definition
NOTICE: merging constraint "ctlt1_a_check" with inherited definition
\d+ ctlt1_inh
- Table "public.ctlt1_inh"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | main | | A
- b | text | | extended | | B
+ Table "public.ctlt1_inh"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | main | | A
+ b | text | | | | extended | | B
Check constraints:
"ctlt1_a_check" CHECK (length(a) > 2)
Inherits: ctlt1
CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3);
NOTICE: merging multiple inherited definitions of column "a"
\d+ ctlt13_inh
- Table "public.ctlt13_inh"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | main | |
- b | text | | extended | |
- c | text | | external | |
+ Table "public.ctlt13_inh"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | main | |
+ b | text | | | | extended | |
+ c | text | | | | external | |
Check constraints:
"ctlt1_a_check" CHECK (length(a) > 2)
"ctlt3_a_check" CHECK (length(a) < 5)
CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
NOTICE: merging column "a" with inherited definition
\d+ ctlt13_like
- Table "public.ctlt13_like"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | main | | A3
- b | text | | extended | |
- c | text | | external | | C
+ Table "public.ctlt13_like"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | main | | A3
+ b | text | | | | extended | |
+ c | text | | | | external | | C
Check constraints:
"ctlt1_a_check" CHECK (length(a) > 2)
"ctlt3_a_check" CHECK (length(a) < 5)
CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL);
\d+ ctlt_all
- Table "public.ctlt_all"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+------+-----------+----------+--------------+-------------
- a | text | not null | main | | A
- b | text | | extended | | B
+ Table "public.ctlt_all"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+------+-----------+----------+---------+----------+--------------+-------------
+ a | text | | not null | | main | | A
+ b | text | | | | extended | | B
Indexes:
"ctlt_all_pkey" PRIMARY KEY, btree (a)
"ctlt_all_b_idx" btree (b)
select * from temp_view_test.tt1
where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1);
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.f1,
tt1.f2,
WHERE tt1.f1 = tx1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = tx1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.f1,
tt1.f2,
WHERE tt1.f1 = a2.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.y1,
tt1.f2,
ALTER TABLE tx1 RENAME TO a1;
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.f1,
tt1.f2,
WHERE tt1.f1 = a1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = a1_1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.f1,
tt1.f2,
WHERE tt1.f1 = a2.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.y1,
tt1.f2,
ALTER TABLE tt1 RENAME TO a2;
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a2.f1,
a2.f2,
WHERE a2.f1 = a1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = a1_1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a2.f1,
a2.f2,
WHERE a2.f1 = a2_1.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.y1,
tt1.f2,
ALTER TABLE a1 RENAME TO tt1;
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a2.f1,
a2.f2,
WHERE a2.f1 = tt1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = tt1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a2.f1,
a2.f2,
WHERE a2.f1 = a2_1.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.y1,
tt1.f2,
ALTER TABLE a2 RENAME TO tx1;
ALTER TABLE tx1 SET SCHEMA temp_view_test;
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tx1.f1,
tx1.f2,
WHERE tx1.f1 = tt1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = tt1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tx1.f1,
tx1.f2,
WHERE tx1.f1 = a2.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tt1.y1,
tt1.f2,
ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2;
ALTER TABLE tmp1 RENAME TO tx1;
\d+ aliased_view_1
- View "testviewschm2.aliased_view_1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tx1.f1,
tx1.f2,
WHERE tx1.f1 = tt1.x1));
\d+ aliased_view_2
- View "testviewschm2.aliased_view_2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT a1.f1,
a1.f2,
WHERE a1.f1 = tt1.x1));
\d+ aliased_view_3
- View "testviewschm2.aliased_view_3"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- f1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_3"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ f1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tx1.f1,
tx1.f2,
WHERE tx1.f1 = a2.x1));
\d+ aliased_view_4
- View "testviewschm2.aliased_view_4"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+----------+-------------
- y1 | integer | | plain |
- f2 | integer | | plain |
- f3 | text | | extended |
+ View "testviewschm2.aliased_view_4"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+----------+-------------
+ y1 | integer | | | | plain |
+ f2 | integer | | | | plain |
+ f3 | text | | | | extended |
View definition:
SELECT tx1.y1,
tx1.f2,
COMMENT ON FOREIGN TABLE ft1 IS 'ft1';
COMMENT ON COLUMN ft1.c1 IS 'ft1.c1';
\d+ ft1
- Foreign table "public.ft1"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+--------------------------------+----------+--------------+-------------
- c1 | integer | not null | ("param 1" 'val1') | plain | | ft1.c1
- c2 | text | | (param2 'val2', param3 'val3') | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft1"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+--------------------------------+----------+--------------+-------------
+ c1 | integer | | not null | | ("param 1" 'val1') | plain | | ft1.c1
+ c2 | text | | | | (param2 'val2', param3 'val3') | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"ft1_c2_check" CHECK (c2 <> ''::text)
"ft1_c3_check" CHECK (c3 >= '01-01-1994'::date AND c3 <= '01-31-1994'::date)
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1;
ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STORAGE PLAIN;
\d+ ft1
- Foreign table "public.ft1"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+--------------------------------+----------+--------------+-------------
- c1 | integer | not null | ("param 1" 'val1') | plain | 10000 |
- c2 | text | | (param2 'val2', param3 'val3') | extended | |
- c3 | date | | | plain | |
- c4 | integer | default 0 | | plain | |
- c5 | integer | | | plain | |
- c6 | integer | not null | | plain | |
- c7 | integer | | (p1 'v1', p2 'v2') | plain | |
- c8 | text | | (p2 'V2') | plain | |
- c9 | integer | | | plain | |
- c10 | integer | | (p1 'v1') | plain | |
+ Foreign table "public.ft1"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+--------------------------------+----------+--------------+-------------
+ c1 | integer | | not null | | ("param 1" 'val1') | plain | 10000 |
+ c2 | text | | | | (param2 'val2', param3 'val3') | extended | |
+ c3 | date | | | | | plain | |
+ c4 | integer | | | 0 | | plain | |
+ c5 | integer | | | | | plain | |
+ c6 | integer | | not null | | | plain | |
+ c7 | integer | | | | (p1 'v1', p2 'v2') | plain | |
+ c8 | text | | | | (p2 'V2') | plain | |
+ c9 | integer | | | | | plain | |
+ c10 | integer | | | | (p1 'v1') | plain | |
Check constraints:
"ft1_c2_check" CHECK (c2 <> ''::text)
"ft1_c3_check" CHECK (c3 >= '01-01-1994'::date AND c3 <= '01-31-1994'::date)
ALTER FOREIGN TABLE foreign_schema.ft1 RENAME c1 TO foreign_column_1;
ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1;
\d foreign_schema.foreign_table_1
- Foreign table "foreign_schema.foreign_table_1"
- Column | Type | Modifiers | FDW Options
-------------------+---------+-----------+--------------------------------
- foreign_column_1 | integer | not null | ("param 1" 'val1')
- c2 | text | | (param2 'val2', param3 'val3')
- c3 | date | |
- c4 | integer | default 0 |
- c5 | integer | |
- c6 | integer | not null |
- c7 | integer | | (p1 'v1', p2 'v2')
- c8 | text | | (p2 'V2')
- c10 | integer | | (p1 'v1')
+ Foreign table "foreign_schema.foreign_table_1"
+ Column | Type | Collation | Nullable | Default | FDW Options
+------------------+---------+-----------+----------+---------+--------------------------------
+ foreign_column_1 | integer | | not null | | ("param 1" 'val1')
+ c2 | text | | | | (param2 'val2', param3 'val3')
+ c3 | date | | | |
+ c4 | integer | | | 0 |
+ c5 | integer | | | |
+ c6 | integer | | not null | |
+ c7 | integer | | | | (p1 'v1', p2 'v2')
+ c8 | text | | | | (p2 'V2')
+ c10 | integer | | | | (p1 'v1')
Check constraints:
"ft1_c2_check" CHECK (c2 <> ''::text)
"ft1_c3_check" CHECK (c3 >= '01-01-1994'::date AND c3 <= '01-31-1994'::date)
CREATE FOREIGN TABLE ft2 () INHERITS (pt1)
SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value');
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
DROP FOREIGN TABLE ft2;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
CREATE FOREIGN TABLE ft2 (
c1 integer NOT NULL,
c3 date
) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value');
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
ALTER FOREIGN TABLE ft2 INHERIT pt1;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
NOTICE: merging column "c2" with inherited definition
NOTICE: merging column "c3" with inherited definition
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
ft3
\d+ ct3
- Table "public.ct3"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.ct3"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Inherits: ft2
\d+ ft3
- Foreign table "public.ft3"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft3"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
Inherits: ft2
ALTER TABLE pt1 ADD COLUMN c7 integer NOT NULL;
ALTER TABLE pt1 ADD COLUMN c8 integer;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
- c4 | integer | | plain | |
- c5 | integer | default 0 | plain | |
- c6 | integer | | plain | |
- c7 | integer | not null | plain | |
- c8 | integer | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
+ c4 | integer | | | | plain | |
+ c5 | integer | | | 0 | plain | |
+ c6 | integer | | | | plain | |
+ c7 | integer | | not null | | plain | |
+ c8 | integer | | | | plain | |
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
- c4 | integer | | | plain | |
- c5 | integer | default 0 | | plain | |
- c6 | integer | | | plain | |
- c7 | integer | not null | | plain | |
- c8 | integer | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
+ c4 | integer | | | | | plain | |
+ c5 | integer | | | 0 | | plain | |
+ c6 | integer | | | | | plain | |
+ c7 | integer | | not null | | | plain | |
+ c8 | integer | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
ft3
\d+ ct3
- Table "public.ct3"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | |
- c2 | text | | extended | |
- c3 | date | | plain | |
- c4 | integer | | plain | |
- c5 | integer | default 0 | plain | |
- c6 | integer | | plain | |
- c7 | integer | not null | plain | |
- c8 | integer | | plain | |
+ Table "public.ct3"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
+ c4 | integer | | | | plain | |
+ c5 | integer | | | 0 | plain | |
+ c6 | integer | | | | plain | |
+ c7 | integer | | not null | | plain | |
+ c8 | integer | | | | plain | |
Inherits: ft2
\d+ ft3
- Foreign table "public.ft3"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
- c4 | integer | | | plain | |
- c5 | integer | default 0 | | plain | |
- c6 | integer | | | plain | |
- c7 | integer | not null | | plain | |
- c8 | integer | | | plain | |
+ Foreign table "public.ft3"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
+ c4 | integer | | | | | plain | |
+ c5 | integer | | | 0 | | plain | |
+ c6 | integer | | | | | plain | |
+ c7 | integer | | not null | | | plain | |
+ c8 | integer | | | | | plain | |
Server: s0
Inherits: ft2
ALTER TABLE pt1 ALTER COLUMN c8 SET STATISTICS -1;
ALTER TABLE pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
- c4 | integer | default 0 | plain | |
- c5 | integer | | plain | |
- c6 | integer | not null | plain | |
- c7 | integer | | plain | |
- c8 | text | | external | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
+ c4 | integer | | | 0 | plain | |
+ c5 | integer | | | | plain | |
+ c6 | integer | | not null | | plain | |
+ c7 | integer | | | | plain | |
+ c8 | text | | | | external | |
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | 10000 |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
- c4 | integer | default 0 | | plain | |
- c5 | integer | | | plain | |
- c6 | integer | not null | | plain | |
- c7 | integer | | | plain | |
- c8 | text | | | external | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | 10000 |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
+ c4 | integer | | | 0 | | plain | |
+ c5 | integer | | | | | plain | |
+ c6 | integer | | not null | | | plain | |
+ c7 | integer | | | | | plain | |
+ c8 | text | | | | | external | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
ALTER TABLE pt1 DROP COLUMN c7;
ALTER TABLE pt1 DROP COLUMN c8;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | 10000 |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | 10000 |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Server: s0
FDW Options: (delimiter ',', quote '"', "be quoted" 'value')
Inherits: pt1
-- child does not inherit NO INHERIT constraints
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk1" CHECK (c1 > 0) NO INHERIT
"pt1chk2" CHECK (c2 <> ''::text)
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | 10000 |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | 10000 |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
Server: s0
ALTER FOREIGN TABLE ft2 INHERIT pt1;
-- child does not inherit NO INHERIT constraints
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk1" CHECK (c1 > 0) NO INHERIT
"pt1chk2" CHECK (c2 <> ''::text)
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
Server: s0
INSERT INTO pt1 VALUES (1, 'pt1'::text, '1994-01-01'::date);
ALTER TABLE pt1 ADD CONSTRAINT pt1chk3 CHECK (c2 <> '') NOT VALID;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk3" CHECK (c2 <> ''::text) NOT VALID
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
"pt1chk3" CHECK (c2 <> ''::text) NOT VALID
-- VALIDATE CONSTRAINT need do nothing on foreign tables
ALTER TABLE pt1 VALIDATE CONSTRAINT pt1chk3;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk3" CHECK (c2 <> ''::text)
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
"pt1chk3" CHECK (c2 <> ''::text)
-- OID system column
ALTER TABLE pt1 SET WITH OIDS;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk3" CHECK (c2 <> ''::text)
Child tables: ft2
Has OIDs: yes
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
"pt1chk3" CHECK (c2 <> ''::text)
ERROR: cannot drop inherited column "oid"
ALTER TABLE pt1 SET WITHOUT OIDS;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- c1 | integer | not null | plain | 10000 |
- c2 | text | | extended | |
- c3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ c1 | integer | | not null | | plain | 10000 |
+ c2 | text | | | | extended | |
+ c3 | date | | | | plain | |
Check constraints:
"pt1chk3" CHECK (c2 <> ''::text)
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- c1 | integer | not null | | plain | |
- c2 | text | | | extended | |
- c3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ c1 | integer | | not null | | | plain | |
+ c2 | text | | | | | extended | |
+ c3 | date | | | | | plain | |
Check constraints:
"pt1chk2" CHECK (c2 <> ''::text)
"pt1chk3" CHECK (c2 <> ''::text)
-- changes name of a constraint recursively
ALTER TABLE pt1 RENAME CONSTRAINT pt1chk3 TO f2_check;
\d+ pt1
- Table "public.pt1"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- f1 | integer | not null | plain | 10000 |
- f2 | text | | extended | |
- f3 | date | | plain | |
+ Table "public.pt1"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ f1 | integer | | not null | | plain | 10000 |
+ f2 | text | | | | extended | |
+ f3 | date | | | | plain | |
Check constraints:
"f2_check" CHECK (f2 <> ''::text)
Child tables: ft2
\d+ ft2
- Foreign table "public.ft2"
- Column | Type | Modifiers | FDW Options | Storage | Stats target | Description
---------+---------+-----------+-------------+----------+--------------+-------------
- f1 | integer | not null | | plain | |
- f2 | text | | | extended | |
- f3 | date | | | plain | |
+ Foreign table "public.ft2"
+ Column | Type | Collation | Nullable | Default | FDW Options | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+-------------+----------+--------------+-------------
+ f1 | integer | | not null | | | plain | |
+ f2 | text | | | | | extended | |
+ f3 | date | | | | | plain | |
Check constraints:
"f2_check" CHECK (f2 <> ''::text)
"pt1chk2" CHECK (f2 <> ''::text)
-- Test that child does not inherit NO INHERIT constraints
create table c1 () inherits (p1);
\d p1
- Table "public.p1"
- Column | Type | Modifiers
---------+---------+-----------
- ff1 | integer |
+ Table "public.p1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ ff1 | integer | | |
Check constraints:
"p1chk" CHECK (ff1 > 0) NO INHERIT
"p2chk" CHECK (ff1 > 10)
Number of child tables: 1 (Use \d+ to list them.)
\d c1
- Table "public.c1"
- Column | Type | Modifiers
---------+---------+-----------
- ff1 | integer |
+ Table "public.c1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ ff1 | integer | | |
Check constraints:
"p2chk" CHECK (ff1 > 10)
Inherits: p1
DETAIL: Failing row contains (1, -1, 2).
create table c2(f3 int) inherits(p1,p2);
\d c2
- Table "public.c2"
- Column | Type | Modifiers
---------+---------+-----------
- f1 | integer |
- f2 | integer |
- f3 | integer |
+ Table "public.c2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ f1 | integer | | |
+ f2 | integer | | |
+ f3 | integer | | |
Check constraints:
"p2_f2_check" CHECK (f2 > 0)
Inherits: p1,
NOTICE: merging multiple inherited definitions of column "f2"
NOTICE: merging multiple inherited definitions of column "f3"
\d c3
- Table "public.c3"
- Column | Type | Modifiers
---------+---------+-----------
- f1 | integer |
- f2 | integer |
- f3 | integer |
- f4 | integer |
+ Table "public.c3"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ f1 | integer | | |
+ f2 | integer | | |
+ f3 | integer | | |
+ f4 | integer | | |
Check constraints:
"p2_f2_check" CHECK (f2 > 0)
Inherits: c1,
create table cc1 (f2 text, f3 int) inherits (pp1);
alter table pp1 add column a1 int check (a1 > 0);
\d cc1
- Table "public.cc1"
- Column | Type | Modifiers
---------+---------+-----------
- f1 | integer |
- f2 | text |
- f3 | integer |
- a1 | integer |
+ Table "public.cc1"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ f1 | integer | | |
+ f2 | text | | |
+ f3 | integer | | |
+ a1 | integer | | |
Check constraints:
"pp1_a1_check" CHECK (a1 > 0)
Inherits: pp1
NOTICE: merging multiple inherited definitions of column "f1"
NOTICE: merging multiple inherited definitions of column "a1"
\d cc2
- Table "public.cc2"
- Column | Type | Modifiers
---------+------------------+-----------
- f1 | integer |
- a1 | integer |
- f2 | text |
- f3 | integer |
- f4 | double precision |
+ Table "public.cc2"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ f1 | integer | | |
+ a1 | integer | | |
+ f2 | text | | |
+ f3 | integer | | |
+ f4 | double precision | | |
Check constraints:
"pp1_a1_check" CHECK (a1 > 0)
Inherits: pp1,
NOTICE: merging definition of column "a2" for child "cc2"
NOTICE: merging constraint "pp1_a2_check" with inherited definition
\d cc2
- Table "public.cc2"
- Column | Type | Modifiers
---------+------------------+-----------
- f1 | integer |
- a1 | integer |
- f2 | text |
- f3 | integer |
- f4 | double precision |
- a2 | integer |
+ Table "public.cc2"
+ Column | Type | Collation | Nullable | Default
+--------+------------------+-----------+----------+---------
+ f1 | integer | | |
+ a1 | integer | | |
+ f2 | text | | |
+ f3 | integer | | |
+ f4 | double precision | | |
+ a2 | integer | | |
Check constraints:
"pp1_a1_check" CHECK (a1 > 0)
"pp1_a2_check" CHECK (a2 > 0)
ERROR: cannot rename inherited column "aa"
ALTER TABLE inhts RENAME d TO dd;
\d+ inhts
- Table "public.inhts"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- aa | integer | | plain | |
- b | integer | | plain | |
- c | integer | | plain | |
- dd | integer | | plain | |
+ Table "public.inhts"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ aa | integer | | | | plain | |
+ b | integer | | | | plain | |
+ c | integer | | | | plain | |
+ dd | integer | | | | plain | |
Inherits: inht1,
inhs1
NOTICE: merging multiple inherited definitions of column "b"
ALTER TABLE inht1 RENAME aa TO aaa;
\d+ inht4
- Table "public.inht4"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- aaa | integer | | plain | |
- b | integer | | plain | |
- x | integer | | plain | |
- y | integer | | plain | |
- z | integer | | plain | |
+ Table "public.inht4"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ aaa | integer | | | | plain | |
+ b | integer | | | | plain | |
+ x | integer | | | | plain | |
+ y | integer | | | | plain | |
+ z | integer | | | | plain | |
Inherits: inht2,
inht3
ALTER TABLE inht1 RENAME b TO bb; -- to be failed
ERROR: cannot rename inherited column "b"
\d+ inhts
- Table "public.inhts"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- aaaa | integer | | plain | |
- b | integer | | plain | |
- x | integer | | plain | |
- c | integer | | plain | |
- d | integer | | plain | |
+ Table "public.inhts"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ aaaa | integer | | | | plain | |
+ b | integer | | | | plain | |
+ x | integer | | | | plain | |
+ c | integer | | | | plain | |
+ d | integer | | | | plain | |
Inherits: inht2,
inhs1
CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2));
CREATE TABLE test_constraints_inh () INHERITS (test_constraints);
\d+ test_constraints
- Table "public.test_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+-------------------+-----------+----------+--------------+-------------
- id | integer | | plain | |
- val1 | character varying | | extended | |
- val2 | integer | | plain | |
+ Table "public.test_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+-------------------+-----------+----------+---------+----------+--------------+-------------
+ id | integer | | | | plain | |
+ val1 | character varying | | | | extended | |
+ val2 | integer | | | | plain | |
Indexes:
"test_constraints_val1_val2_key" UNIQUE CONSTRAINT, btree (val1, val2)
Child tables: test_constraints_inh
ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key;
\d+ test_constraints
- Table "public.test_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+-------------------+-----------+----------+--------------+-------------
- id | integer | | plain | |
- val1 | character varying | | extended | |
- val2 | integer | | plain | |
+ Table "public.test_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+-------------------+-----------+----------+---------+----------+--------------+-------------
+ id | integer | | | | plain | |
+ val1 | character varying | | | | extended | |
+ val2 | integer | | | | plain | |
Child tables: test_constraints_inh
\d+ test_constraints_inh
- Table "public.test_constraints_inh"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+-------------------+-----------+----------+--------------+-------------
- id | integer | | plain | |
- val1 | character varying | | extended | |
- val2 | integer | | plain | |
+ Table "public.test_constraints_inh"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+-------------------+-----------+----------+---------+----------+--------------+-------------
+ id | integer | | | | plain | |
+ val1 | character varying | | | | extended | |
+ val2 | integer | | | | plain | |
Inherits: test_constraints
DROP TABLE test_constraints_inh;
);
CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints);
\d+ test_ex_constraints
- Table "public.test_ex_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+--------+-----------+---------+--------------+-------------
- c | circle | | plain | |
+ Table "public.test_ex_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+--------+-----------+----------+---------+---------+--------------+-------------
+ c | circle | | | | plain | |
Indexes:
"test_ex_constraints_c_excl" EXCLUDE USING gist (c WITH &&)
Child tables: test_ex_constraints_inh
ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl;
\d+ test_ex_constraints
- Table "public.test_ex_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+--------+-----------+---------+--------------+-------------
- c | circle | | plain | |
+ Table "public.test_ex_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+--------+-----------+----------+---------+---------+--------------+-------------
+ c | circle | | | | plain | |
Child tables: test_ex_constraints_inh
\d+ test_ex_constraints_inh
- Table "public.test_ex_constraints_inh"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+--------+-----------+---------+--------------+-------------
- c | circle | | plain | |
+ Table "public.test_ex_constraints_inh"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+--------+-----------+----------+---------+---------+--------------+-------------
+ c | circle | | | | plain | |
Inherits: test_ex_constraints
DROP TABLE test_ex_constraints_inh;
CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id));
CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints);
\d+ test_primary_constraints
- Table "public.test_primary_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- id | integer | not null | plain | |
+ Table "public.test_primary_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ id | integer | | not null | | plain | |
Indexes:
"test_primary_constraints_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "test_foreign_constraints" CONSTRAINT "test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
\d+ test_foreign_constraints
- Table "public.test_foreign_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- id1 | integer | | plain | |
+ Table "public.test_foreign_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ id1 | integer | | | | plain | |
Foreign-key constraints:
"test_foreign_constraints_id1_fkey" FOREIGN KEY (id1) REFERENCES test_primary_constraints(id)
Child tables: test_foreign_constraints_inh
ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey;
\d+ test_foreign_constraints
- Table "public.test_foreign_constraints"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- id1 | integer | | plain | |
+ Table "public.test_foreign_constraints"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ id1 | integer | | | | plain | |
Child tables: test_foreign_constraints_inh
\d+ test_foreign_constraints_inh
- Table "public.test_foreign_constraints_inh"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- id1 | integer | | plain | |
+ Table "public.test_foreign_constraints_inh"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ id1 | integer | | | | plain | |
Inherits: test_foreign_constraints
DROP TABLE test_foreign_constraints_inh;
insert into inserttest (f4[1].if1, f4[1].if2[2])
select new.f1, new.f2;
\d+ inserttest2
- Table "public.inserttest2"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+--------+-----------+----------+--------------+-------------
- f1 | bigint | | plain | |
- f2 | text | | extended | |
+ Table "public.inserttest2"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+--------+-----------+----------+---------+----------+--------------+-------------
+ f1 | bigint | | | | plain | |
+ f2 | text | | | | extended | |
Rules:
irule1 AS
ON INSERT TO inserttest2 DO INSERT INTO inserttest (f3.if2[1], f3.if2[2])
CREATE INDEX mvtest_aa ON mvtest_bb (grandtot);
-- check that plans seem reasonable
\d+ mvtest_tvm
- Materialized view "public.mvtest_tvm"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- type | text | | extended | |
- totamt | numeric | | main | |
+ Materialized view "public.mvtest_tvm"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ type | text | | | | extended | |
+ totamt | numeric | | | | main | |
View definition:
SELECT mvtest_tv.type,
mvtest_tv.totamt
ORDER BY mvtest_tv.type;
\d+ mvtest_tvm
- Materialized view "public.mvtest_tvm"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- type | text | | extended | |
- totamt | numeric | | main | |
+ Materialized view "public.mvtest_tvm"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ type | text | | | | extended | |
+ totamt | numeric | | | | main | |
View definition:
SELECT mvtest_tv.type,
mvtest_tv.totamt
ORDER BY mvtest_tv.type;
\d+ mvtest_tvvm
- Materialized view "public.mvtest_tvvm"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-----------+---------+--------------+-------------
- grandtot | numeric | | main | |
+ Materialized view "public.mvtest_tvvm"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+---------+---------+--------------+-------------
+ grandtot | numeric | | | | main | |
View definition:
SELECT mvtest_tvv.grandtot
FROM mvtest_tvv;
\d+ mvtest_bb
- Materialized view "public.mvtest_bb"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-----------+---------+--------------+-------------
- grandtot | numeric | | main | |
+ Materialized view "public.mvtest_bb"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+---------+---------+--------------+-------------
+ grandtot | numeric | | | | main | |
Indexes:
"mvtest_aa" btree (grandtot)
View definition:
ALTER MATERIALIZED VIEW mvtest_tvm SET SCHEMA mvtest_mvschema;
\d+ mvtest_tvm
\d+ mvtest_tvmm
- Materialized view "public.mvtest_tvmm"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-----------+---------+--------------+-------------
- grandtot | numeric | | main | |
+ Materialized view "public.mvtest_tvmm"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+---------+---------+--------------+-------------
+ grandtot | numeric | | | | main | |
Indexes:
"mvtest_tvmm_expr" UNIQUE, btree ((grandtot > 0::numeric))
"mvtest_tvmm_pred" UNIQUE, btree (grandtot) WHERE grandtot < 0::numeric
SET search_path = mvtest_mvschema, public;
\d+ mvtest_tvm
- Materialized view "mvtest_mvschema.mvtest_tvm"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+----------+--------------+-------------
- type | text | | extended | |
- totamt | numeric | | main | |
+ Materialized view "mvtest_mvschema.mvtest_tvm"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+----------+--------------+-------------
+ type | text | | | | extended | |
+ totamt | numeric | | | | main | |
View definition:
SELECT mvtest_tv.type,
mvtest_tv.totamt
CREATE VIEW mvtest_vt1 AS SELECT 1 moo;
CREATE VIEW mvtest_vt2 AS SELECT moo, 2*moo FROM mvtest_vt1 UNION ALL SELECT moo, 3*moo FROM mvtest_vt1;
\d+ mvtest_vt2
- View "public.mvtest_vt2"
- Column | Type | Modifiers | Storage | Description
-----------+---------+-----------+---------+-------------
- moo | integer | | plain |
- ?column? | integer | | plain |
+ View "public.mvtest_vt2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+----------+---------+-----------+----------+---------+---------+-------------
+ moo | integer | | | | plain |
+ ?column? | integer | | | | plain |
View definition:
SELECT mvtest_vt1.moo,
2 * mvtest_vt1.moo
CREATE MATERIALIZED VIEW mv_test2 AS SELECT moo, 2*moo FROM mvtest_vt2 UNION ALL SELECT moo, 3*moo FROM mvtest_vt2;
\d+ mv_test2
- Materialized view "public.mv_test2"
- Column | Type | Modifiers | Storage | Stats target | Description
-----------+---------+-----------+---------+--------------+-------------
- moo | integer | | plain | |
- ?column? | integer | | plain | |
+ Materialized view "public.mv_test2"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+----------+---------+-----------+----------+---------+---------+--------------+-------------
+ moo | integer | | | | plain | |
+ ?column? | integer | | | | plain | |
View definition:
SELECT mvtest_vt2.moo,
2 * mvtest_vt2.moo
(5 rows)
\d+ dfview
- View "public.dfview"
- Column | Type | Modifiers | Storage | Description
---------+--------+-----------+---------+-------------
- q1 | bigint | | plain |
- q2 | bigint | | plain |
- c3 | bigint | | plain |
- c4 | bigint | | plain |
+ View "public.dfview"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+--------+-----------+----------+---------+---------+-------------
+ q1 | bigint | | | | plain |
+ q2 | bigint | | | | plain |
+ c3 | bigint | | | | plain |
+ c4 | bigint | | | | plain |
View definition:
SELECT int8_tbl.q1,
int8_tbl.q2,
-- Commit table creation
COMMIT PREPARED 'regress-one';
\d pxtest2
- Table "public.pxtest2"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
+ Table "public.pxtest2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
SELECT * FROM pxtest2;
a
(1 row)
\d test_replica_identity
- Table "public.test_replica_identity"
- Column | Type | Modifiers
---------+---------+--------------------------------------------------------------------
- id | integer | not null default nextval('test_replica_identity_id_seq'::regclass)
- keya | text | not null
- keyb | text | not null
- nonkey | text |
+ Table "public.test_replica_identity"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------------------------------------------------
+ id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass)
+ keya | text | | not null |
+ keyb | text | | not null |
+ nonkey | text | | |
Indexes:
"test_replica_identity_pkey" PRIMARY KEY, btree (id) REPLICA IDENTITY
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
(1 row)
\d test_replica_identity
- Table "public.test_replica_identity"
- Column | Type | Modifiers
---------+---------+--------------------------------------------------------------------
- id | integer | not null default nextval('test_replica_identity_id_seq'::regclass)
- keya | text | not null
- keyb | text | not null
- nonkey | text |
+ Table "public.test_replica_identity"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------------------------------------------------
+ id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass)
+ keya | text | | not null |
+ keyb | text | | not null |
+ nonkey | text | | |
Indexes:
"test_replica_identity_pkey" PRIMARY KEY, btree (id)
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
(1 row)
\d+ test_replica_identity
- Table "public.test_replica_identity"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+--------------------------------------------------------------------+----------+--------------+-------------
- id | integer | not null default nextval('test_replica_identity_id_seq'::regclass) | plain | |
- keya | text | not null | extended | |
- keyb | text | not null | extended | |
- nonkey | text | | extended | |
+ Table "public.test_replica_identity"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------------------------------------------------+----------+--------------+-------------
+ id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass) | plain | |
+ keya | text | | not null | | extended | |
+ keyb | text | | not null | | extended | |
+ nonkey | text | | | | extended | |
Indexes:
"test_replica_identity_pkey" PRIMARY KEY, btree (id)
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
create rule r3 as on delete to rules_src do notify rules_src_deletion;
\d+ rules_src
- Table "public.rules_src"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- f1 | integer | | plain | |
- f2 | integer | | plain | |
+ Table "public.rules_src"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ f1 | integer | | | | plain | |
+ f2 | integer | | | | plain | |
Rules:
r1 AS
ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
create rule r4 as on insert to rules_src do instead insert into rules_log AS trgt SELECT NEW.* RETURNING trgt.f1, trgt.f2;
create rule r5 as on update to rules_src do instead UPDATE rules_log AS trgt SET tag = 'updated' WHERE trgt.f1 = new.f1;
\d+ rules_src
- Table "public.rules_src"
- Column | Type | Modifiers | Storage | Stats target | Description
---------+---------+-----------+---------+--------------+-------------
- f1 | integer | | plain | |
- f2 | integer | | plain | |
+ Table "public.rules_src"
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
+--------+---------+-----------+----------+---------+---------+--------------+-------------
+ f1 | integer | | | | plain | |
+ f2 | integer | | | | plain | |
Rules:
r1 AS
ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text)
(1 row)
\d+ rule_v1
- View "public.rule_v1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
+ View "public.rule_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
View definition:
SELECT rule_t1.a
FROM rule_t1;
--
create view rule_v1 as values(1,2);
\d+ rule_v1
- View "public.rule_v1"
- Column | Type | Modifiers | Storage | Description
----------+---------+-----------+---------+-------------
- column1 | integer | | plain |
- column2 | integer | | plain |
+ View "public.rule_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+---------+---------+-----------+----------+---------+---------+-------------
+ column1 | integer | | | | plain |
+ column2 | integer | | | | plain |
View definition:
VALUES (1,2);
drop view rule_v1;
create view rule_v1(x) as values(1,2);
\d+ rule_v1
- View "public.rule_v1"
- Column | Type | Modifiers | Storage | Description
----------+---------+-----------+---------+-------------
- x | integer | | plain |
- column2 | integer | | plain |
+ View "public.rule_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+---------+---------+-----------+----------+---------+---------+-------------
+ x | integer | | | | plain |
+ column2 | integer | | | | plain |
View definition:
SELECT "*VALUES*".column1 AS x,
"*VALUES*".column2
drop view rule_v1;
create view rule_v1(x) as select * from (values(1,2)) v;
\d+ rule_v1
- View "public.rule_v1"
- Column | Type | Modifiers | Storage | Description
----------+---------+-----------+---------+-------------
- x | integer | | plain |
- column2 | integer | | plain |
+ View "public.rule_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+---------+---------+-----------+----------+---------+---------+-------------
+ x | integer | | | | plain |
+ column2 | integer | | | | plain |
View definition:
SELECT v.column1 AS x,
v.column2
drop view rule_v1;
create view rule_v1(x) as select * from (values(1,2)) v(q,w);
\d+ rule_v1
- View "public.rule_v1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- x | integer | | plain |
- w | integer | | plain |
+ View "public.rule_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ x | integer | | | | plain |
+ w | integer | | | | plain |
View definition:
SELECT v.q AS x,
v.w
CREATE VIEW test_tablesample_v2 AS
SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (99);
\d+ test_tablesample_v1
- View "public.test_tablesample_v1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- id | integer | | plain |
+ View "public.test_tablesample_v1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ id | integer | | | | plain |
View definition:
SELECT test_tablesample.id
FROM test_tablesample TABLESAMPLE system ((10 * 2)) REPEATABLE (2);
\d+ test_tablesample_v2
- View "public.test_tablesample_v2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- id | integer | | plain |
+ View "public.test_tablesample_v2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ id | integer | | | | plain |
View definition:
SELECT test_tablesample.id
FROM test_tablesample TABLESAMPLE system (99);
\set QUIET true
-- Describe view should list triggers
\d main_view
- View "public.main_view"
- Column | Type | Modifiers
---------+---------+-----------
- a | integer |
- b | integer |
+ View "public.main_view"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ a | integer | | |
+ b | integer | | |
Triggers:
after_del_stmt_trig AFTER DELETE ON main_view FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_del_stmt')
after_ins_stmt_trig AFTER INSERT ON main_view FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_ins_stmt')
DROP TRIGGER instead_of_insert_trig ON main_view;
DROP TRIGGER instead_of_delete_trig ON main_view;
\d+ main_view
- View "public.main_view"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
- b | integer | | plain |
+ View "public.main_view"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
+ b | integer | | | | plain |
View definition:
SELECT main_table.a,
main_table.b
(0 rows)
\d persons
- Table "public.persons"
- Column | Type | Modifiers
---------+---------+-----------
- id | integer |
- name | text |
+ Table "public.persons"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ id | integer | | |
+ name | text | | |
Typed table of type: person_type
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
UNIQUE (name)
);
\d persons2
- Table "public.persons2"
- Column | Type | Modifiers
---------+---------+-----------
- id | integer | not null
- name | text |
+ Table "public.persons2"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+---------
+ id | integer | | not null |
+ name | text | | |
Indexes:
"persons2_pkey" PRIMARY KEY, btree (id)
"persons2_name_key" UNIQUE CONSTRAINT, btree (name)
name WITH OPTIONS DEFAULT ''
);
\d persons3
- Table "public.persons3"
- Column | Type | Modifiers
---------+---------+------------------
- id | integer | not null
- name | text | default ''::text
+ Table "public.persons3"
+ Column | Type | Collation | Nullable | Default
+--------+---------+-----------+----------+----------
+ id | integer | | not null |
+ name | text | | | ''::text
Indexes:
"persons3_pkey" PRIMARY KEY, btree (id)
Typed table of type: person_type
CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b
WITH LOCAL CHECK OPTION;
\d+ rw_view1
- View "public.rw_view1"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
- b | integer | | plain |
+ View "public.rw_view1"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
+ b | integer | | | | plain |
View definition:
SELECT base_tbl.a,
base_tbl.b
CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
WITH CHECK OPTION; -- implicitly cascaded
\d+ rw_view2
- View "public.rw_view2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
+ View "public.rw_view2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
View definition:
SELECT rw_view1.a
FROM rw_view1
CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10
WITH LOCAL CHECK OPTION;
\d+ rw_view2
- View "public.rw_view2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
+ View "public.rw_view2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
View definition:
SELECT rw_view1.a
FROM rw_view1
DETAIL: Failing row contains (30).
ALTER VIEW rw_view2 RESET (check_option);
\d+ rw_view2
- View "public.rw_view2"
- Column | Type | Modifiers | Storage | Description
---------+---------+-----------+---------+-------------
- a | integer | | plain |
+ View "public.rw_view2"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+---------+-----------+----------+---------+---------+-------------
+ a | integer | | | | plain |
View definition:
SELECT rw_view1.a
FROM rw_view1
)
SELECT sum(n) FROM t;
\d+ sums_1_100
- View "public.sums_1_100"
- Column | Type | Modifiers | Storage | Description
---------+--------+-----------+---------+-------------
- sum | bigint | | plain |
+ View "public.sums_1_100"
+ Column | Type | Collation | Nullable | Default | Storage | Description
+--------+--------+-----------+----------+---------+---------+-------------
+ sum | bigint | | | | plain |
View definition:
WITH RECURSIVE t(n) AS (
VALUES (1)