Re: CTAS not honoring NOT NULL, DEFAULT modifiers - Mailing list pgsql-hackers

From Nikhil Sontakke
Subject Re: CTAS not honoring NOT NULL, DEFAULT modifiers
Date
Msg-id i2ja301bfd91004190534v18e8d924r99d8e0c792d7389e@mail.gmail.com
Whole thread Raw
In response to Re: CTAS not honoring NOT NULL, DEFAULT modifiers  (Magnus Hagander <magnus@hagander.net>)
Responses Re: CTAS not honoring NOT NULL, DEFAULT modifiers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
>> Was wondering what are the standards for CTAS. Oracle seems to honor
>> the NOT NULL modifier. This might be a bug if we do not honor
>> modifiers in CTAS.
>
> Given that CREATE TABLE AS creates a table based on the result of a
> query, it seems pretty logical that constraints wouldn't be copied
> over - they're part of the table, they're not visible in a query
> result.
>

Yeah agreed, it is just a SELECT query afterall.

> The documentation pretty clearly says you should use CREATE TABLE LIKE
> if you want to copy the constraints over, if you look at the CREATE
> TABLE manpage (not on the CREATE TABLE AS though - perhaps a note
> should be added there?)
>

I think the semantics should be pretty ok as is. But I saw another DB
honoring the NOT NULL modifiers and hence the wonder if there is
something about this in the standards.

Regards,
Nikhils
-- 
http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: [GENERAL] trouble with to_char('L')
Next
From: Tom Lane
Date:
Subject: Re: CTAS not honoring NOT NULL, DEFAULT modifiers