From e375044d55809d239be33f31c4efa8410790d3f0 Mon Sep 17 00:00:00 2001 From: "David G. Johnston" Date: Mon, 22 Apr 2024 11:51:53 -0700 Subject: [PATCH] doc: create table doc enhancements --- doc/src/sgml/ref/create_table.sgml | 37 +++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 02f31d2d6f..9a5dafb9af 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -21,8 +21,8 @@ PostgreSQL documentation -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name ( [ - { column_name data_type [ STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT } ] [ COMPRESSION compression_method ] [ COLLATE collation ] [ column_constraint [ ... ] ] +CREATE [ persistence_mode ] TABLE [ IF NOT EXISTS ] table_name ( [ + { column_name data_type [ column_storage ] [ COLLATE collation ] [ column_constraint [ ... ] ] | table_constraint | LIKE source_table [ like_option ... ] } [, ... ] @@ -34,7 +34,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] [ TABLESPACE tablespace_name ] -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name +CREATE [ persistence_mode ] TABLE [ IF NOT EXISTS ] table_name OF type_name [ ( { column_name [ WITH OPTIONS ] [ column_constraint [ ... ] ] | table_constraint } @@ -46,7 +46,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] [ TABLESPACE tablespace_name ] -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name +CREATE [ persistence_mode ] TABLE [ IF NOT EXISTS ] table_name PARTITION OF parent_table [ ( { column_name [ WITH OPTIONS ] [ column_constraint [ ... ] ] | table_constraint } @@ -58,7 +58,16 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] [ TABLESPACE tablespace_name ] -where column_constraint is: +where persistence_mode is: + +[ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | +UNLOGGED + +and column_storage is: + +STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT } [ COMPRESSION compression_method ] + +and column_constraint is: [ CONSTRAINT constraint_name ] { NOT NULL | @@ -118,11 +127,21 @@ WITH ( MODULUS numeric_literal, REM Description - CREATE TABLE will create a new, initially empty table + CREATE TABLE will create a new, initially empty, table in the current database. The table will be owned by the user issuing the command. + + The reliability characteristics of a table are governed by its + persistence mode. The default mode is described + here + There are two alternative modes that can be specified during + table creation: + temporary and + unlogged. + + If a schema name is given (for example, CREATE TABLE myschema.mytable ...) then the table is created in the specified @@ -221,6 +240,12 @@ WITH ( MODULUS numeric_literal, REM If this is specified, any sequences created together with the unlogged table (for identity or serial columns) are also created as unlogged. + + + If specified on a partitioned table the property is recorded but ignored: + the entire partitioned table is not automatically truncated after a crash + or unclean shutdown. + -- 2.34.1