-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
> Do any databases support CREATE TABLE statement with fields
> having a DEFAULT clause without a NOT NULL?
PostgreSQL does. Just think of every column as having an implicit
default of NULL. PostgreSQL lets you change that default, and
insert to it specifically:
psql=> create table foo (bar integer, baz integer default 42);
CREATE TABLE
psql=> insert into foo values (23, default);
INSERT 101036 1
psql=> select * from foo;
bar | baz
-----+-----
23 | 42
This also works if you don't specify a value at all, since no
value assumes the default:
psql=> insert into foo(bar) values (100);
INSERT 101037 1
psql=> select * from foo;
bar | baz
-----+-----
23 | 42
100 | 42
There is also a third form:
psql=> insert into foo default values;
INSERT 101037 1
psql=> select * from foo;
bar | baz
-----+-----
23 | 42
100 | 42
| 42
Note that "bar" in the final example uses a default of NULL.
--
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200408291810
-----BEGIN PGP SIGNATURE-----
iD8DBQFBMlR6vJuQZxSWSsgRAiyKAKCqjx/4HGMRzOrcqO0iW55LUSGXvACgxqAj
BTP/cXNkU5IR3dizCNZxUJ8=
=wqFw
-----END PGP SIGNATURE-----