Re: [SQL] NULL

From: jose soares <jose(at)sferacarta(dot)com>
To: Jan Wieck <wieck(at)debis(dot)com>
Cc: bruce(at)cenderis(dot)demon(dot)co(dot)uk, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] NULL
Date: 1999-11-17 13:56:16
Message-ID: 3832B3FF.A3F3F9F1@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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-create the 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
CONSTRAINT con1 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é

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 1999-11-17 18:31:28 Re: [SQL] NULL
Previous Message Stoyan Genov 1999-11-17 13:42:46 Building "ON DELETE" rules to keep the referential integrity of a database