# HG changeset patch # User Oleksandr Gavenko # Date 1619078224 -10800 # Node ID 8e8c8adde58572c04cc44dadf4b38e5078dbc2e2 # Parent 04649fd8a3948f99e2db1a596024568981ee7f50 Copy tables. diff -r 04649fd8a394 -r 8e8c8adde585 postgres.rst --- a/postgres.rst Fri Apr 16 00:11:21 2021 +0300 +++ b/postgres.rst Thu Apr 22 10:57:04 2021 +0300 @@ -596,6 +596,26 @@ $ psql -U $USER -h $HOST $DB -c "\\copy tbl_name from 'my.csv' csv" +Copy tables +=========== + +Create table *with* data copying using another table (no constraints & indices are recreated, +including PK):: + + CREATE TABLE mycopy AS TABLE myorig; + +Create table *without* data copying using another table:: + + CREATE TABLE mycopy AS TABLE myorig WITH NO DATA; + +Create table from select and copy data (no constraints & indices are recreated, including PK):: + + CREATE TABLE mycopy AS (SELECT * FROM myorig); + +Create table from select (without copying data):: + + CREATE TABLE mycopy AS (SELECT * FROM myorig) WITH NO DATA; + JDBC driver ===========