From: Vik Fearing <vik@postgresfriends.org>
To: Xiao, Bing (Benny) <bing.xiao@dxc.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.
Date: Thu, 21 Oct 2021 12:25:32 +0200
Message-ID: <eb300c73-9f98-d243-c762-88e47d88c2d6@postgresfriends.org> (raw)
In-Reply-To: <DM5PR0101MB3002C39B637255E03599448AF9BF9@DM5PR0101MB3002.prod.exchangelabs.com>
References: <DM5PR0101MB3002C39B637255E03599448AF9BF9@DM5PR0101MB3002.prod.exchangelabs.com>
On 10/21/21 7:47 AM, Xiao, Bing (Benny) wrote:
>
> 1. Create back up table.
>
> create table contact_bckp as table contacts with data;
This is not the correct way to do this. Do it this way instead:
BEGIN;
CREATE TABLE contact_bckp (LIKE contacts INCLUDING ALL);
INSERT INTO contact_bckp TABLE contacts;
COMMIT;
--
Vik Fearing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: vik@postgresfriends.org, bing.xiao@dxc.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.
In-Reply-To: <eb300c73-9f98-d243-c762-88e47d88c2d6@postgresfriends.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox