Re: [SQL] NULL - Mailing list pgsql-sql

From jose soares
Subject Re: [SQL] NULL
Date
Msg-id 3832B3FF.A3F3F9F1@sferacarta.com
Whole thread Raw
In response to Re: [SQL] NULL  (wieck@debis.com (Jan Wieck))
Responses Re: [SQL] NULL  (wieck@debis.com (Jan Wieck))
List pgsql-sql

Jan Wieck ha scritto:

> > > > It suppose to mean that NULLs are explicitly allowed in
> > > > this field.
> > > > Is this required by SQL-92?
> > >
> > > No, it's not required.  This came up before with the examples from
> > > "The Practical SQL Handbook".  It would be nice to allow it, but there
> > > was some reason why to do so would be non-trivial, which I forget.
> > > Anyway, it's not in SQL-92.
> > >
> > Sorry, I don't understand why we need this feature. This is completely ou=
> > t
> > of standard.
> >
> > What's that mean ?
> >
> > -  Is it a constraint to allow only NULL values ?  (unuseful)
>
>     Useless? I NEED IT - URGENT - NOW - YESTERDAY.
>
>     Then  I  could  create my tables with all required fields for
>     the future, but prevent that  someone  stores  data  in  them
>     until I drop the constraint.

Maybe I miss something here, Jan...I think you don't need such thing to do this
kind of work.

To drop the constraint you have:   1) download the table   2) modify the table structure (without constraint NULL)   3)
re-createthe table   4) reload it again.
 

You have the same effect as:   1) download the table   2) add new filelds to table structure   3) re-create the table
4)reload it again
 

...but, if want these fields from the begining you may create a CHECK contraint
for the field, like:

CREATE TABLE distributors (       did      DECIMAL(3),       name     VARCHAR(40),       avoid    INTEGER
CONSTRAINTcon1 CHECK (avoid is NULL)       );
 

insert into distributors values (33,'PIPPO',123);
ERROR:  ExecAppend: rejected due to CHECK constraint con1
insert into distributors values (33,'PIPPO',NULL);
INSERT 1484300 1
select * from distributors;
did|name |avoid
---+-----+-----33|PIPPO|
(1 row)

...and this is SQL-92 Standard   ;)

José



pgsql-sql by date:

Previous
From: "Stoyan Genov"
Date:
Subject: Building "ON DELETE" rules to keep the referential integrity of a database
Next
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] NULL