-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message
> Which database server is this? This is definitely the behavior of MySQL, PostgreSQL, and Oracle, and I'm pretty sure most others follow it as well. > And, can you omit the name of the column you want defaulted, and does this > server then insert the default value? Yes. One way to think about this is to realize that *all* columns have an automatic default of NULL, we are just changing it to something a little more useful: CREATE TABLE foo ( a int, b int DEFAULT 22, c int DEFAULT stockprice('RHAT') ); is completely identical to: CREATE TABLE foo ( a int DEFAULT NULL, b int DEFAULT 22, c int DEFAULT stockprice('RHAT') ); -- A PostgreSQL example. -- stockprice() is a pl/perl function that returns the real-time value -- (in cents) of RedHat stock via a web service. INSERT INTO foo(b) VALUES (14); SELECT * FROM foo; a | b | c ---+----+------ | 14 | 3025 -- We triggered the DEFAULT values of both a and c because we did -- not specify them INSERT INTO foo(a,b,c) VALUES (7,DEFAULT,47); SELECT * FROM foo; a | b | c ---+----+------ | 14 | 3025 7 | 22 | 47 -- We told b to use its default value explicitly INSERT INTO foo(a,b,c) VALUES (DEFAULT,DEFAULT,NULL); SELECT * FROM foo; a | b | c ---+----+------ | 14 | 3025 7 | 22 | 47 | 22 | -- We told a and b to use their default values, and set c explicitly It's late here, so hope that made sense. :) -- Greg Sabino Mullane [EMAIL PROTECTED] PGP Key: 0x14964AC8 200604270030 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFEUEo0vJuQZxSWSsgRAmAYAKDcMYGCUfTkpsVBGvTDr+rD1sjf/gCdGvYI lpjCTQT14ynvtN2LOV++rLs= =ww4D -----END PGP SIGNATURE-----