Re: [SQL] NULL
Jose Soares <jose@sferacarta.com>
From: jose soares <jose@sferacarta.com>
To: Jan Wieck <wieck@debis.com>
Cc: bruce@cenderis.demon.co.uk, pgsql-sql@postgresql.org
Date: 1999-11-17T13:56:16Z
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é