Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: "Xiao, Bing (Benny)" <bing(dot)xiao(at)dxc(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.
Date: 2021-10-21 10:25:32
Message-ID: eb300c73-9f98-d243-c762-88e47d88c2d6@postgresfriends.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Francisco Olarte 2021-10-21 11:40:15 Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.
Previous Message PG Bug reporting form 2021-10-21 09:48:39 BUG #17240: <timestamptz> at time zone ... ; wrong result