On 02/01/2015 05:42 PM, Bryan Pendleton wrote:
> You have to spell out the columns you are inserting into,
> unless the columns with default values are the last columns
> in the table. In that case you can just omit them in the insert
>
I'm pretty sure it's a bit more flexible than that. I believe
that if you don't say NOT NULL, and you don't have a DEFAULT
clause, then DEFAULT NULL is automatic.
And I believe you can name the columns in any order (so long
as they line up with the VALUES values), so they don't have
to be the last columns in the table.
So you can INSERT INTO T (c, f, a, g, b ) VALUES ( .. )
and columns d and e and h will get NULL values since they
weren't mentioned in the insert.
That is indeed much more convenient. Thanks for pointing that out :)
--
Regards,
Dyre