Re: Is this a buggy behavior? - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: Is this a buggy behavior?
Date
Msg-id 1a07537f-f450-4a9c-83d8-364edd712706@a-kretschmer.de
Whole thread Raw
In response to Re: Is this a buggy behavior?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
Responses Re: Is this a buggy behavior?  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
List pgsql-general

Am 24.03.24 um 16:41 schrieb Thiemo Kellner:
>
>
> Am 24.03.2024 um 16:36 schrieb Andreas Kretschmer:
>> the null-able constraint addition to a column is pointless because by 
>> default all columns are nullable. definition as a primary key adds 
>> the not null constraint.
>
> While this is certainly true, I do not see why the information that a 
> not null constraint is to be created or has been created is not 
> available.
>
>

postgres=# create table bla(i int null primary key);
CREATE TABLE
postgres=# \d bla
                 Table "public.bla"
  Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
  i      | integer |           | not null |
Indexes:
     "bla_pkey" PRIMARY KEY, btree (i)

postgres=# drop table bla;
DROP TABLE
postgres=# create table bla(i int not null primary key);
CREATE TABLE
postgres=# \d bla
                 Table "public.bla"
  Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
  i      | integer |           | not null |
Indexes:
     "bla_pkey" PRIMARY KEY, btree (i)

postgres=#


as you can see, there is no difference.  the PK-Constraint is the 
important thing here.

Andreas



-- 
Andreas Kretschmer
CYBERTEC PostgreSQL Services and Support




pgsql-general by date:

Previous
From: Thiemo Kellner
Date:
Subject: Re: Is this a buggy behavior?
Next
From: Erik Wienhold
Date:
Subject: Re: Is this a buggy behavior?