Re: CTAS not honoring NOT NULL, DEFAULT modifiers

From: Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CTAS not honoring NOT NULL, DEFAULT modifiers
Date: 2010-04-19 12:34:32
Message-ID: i2ja301bfd91004190534v18e8d924r99d8e0c792d7389e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-04-19 13:48:01 Re: CTAS not honoring NOT NULL, DEFAULT modifiers
Previous Message Magnus Hagander 2010-04-19 12:02:32 Re: [GENERAL] trouble with to_char('L')