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

Поиск
Список
Период
Сортировка
От Xiao, Bing (Benny)
Тема Null option and Default value Lost when use CREATE TABLE AS to backup a table.
Дата
Msg-id DM5PR0101MB3002C39B637255E03599448AF9BF9@DM5PR0101MB3002.prod.exchangelabs.com
обсуждение исходный текст
Ответы Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.  (Vik Fearing <vik@postgresfriends.org>)
Re: Null option and Default value Lost when use CREATE TABLE AS to backup a table.  (Francisco Olarte <folarte@peoplecall.com>)
Список pgsql-bugs

Hi Team,

 

Null option(NOT NULL) and Default value lost when I try to copy a table with CREATE TABLE AS statement.

 

List the test step as below.

  1. PostgreSQL version.

 

 

  1. Create test table as below.

 

CREATE TABLE contact(

    id SERIAL PRIMARY KEY,

    first_name VARCHAR NOT NULL DEFAULT 'Benny',

    last_name VARCHAR NOT NULL,

    email VARCHAR NOT NULL UNIQUE

);

 

  1. Insert the test data to table Contact.

 

INSERT INTO contact(first_name, last_name, email)

VALUES('John','Doe','john.doe@postgresqltutorial.com'),

      ('David','William','david.william@postgresqltutorial.com');

 

  1. Create back up table.

 

               create table contact_bckp as table contacts with data;

 

  1. Test to insert data with null in column last_name. Failed in table contact.

 

INSERT INTO contact(first_name, last_name, email) VALUES('benny',null,'john.doe@postgresqltutorial.com');

 

 

  1. Test to insert data with null in column last_name. Succeed  in table contact_bckp. And even the PK column been set to null.

 

       INSERT INTO contact_bckp(first_name, last_name, email)  VALUES('benny',null,'john.doe@postgresqltutorial.com');

  1. Check the table definition as below. contact_bckp lost null option and default value compare to table contact.

 

 

Best Regards.

Benny

Email:  bing.xiao@dxc.com



Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17235: PQsendQuery (with two sql) after PQenterPipelineMode cause ERROR
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #17240: at time zone ... ; wrong result