> > INSERT INTO my_table VALUES (a, b, c, DEFAULT, x, y, z, ...);
>
> I think that is legal SQL92 syntax, but Postgres doesn't accept it
> at present.
>
> The usual recommendation is to call out the columns you are loading
> explicitly:
>
> INSERT INTO my_table(a,b,d) VALUES (val-for-a, val-for-b, val-for-d);
>
> The ones you don't load get their default values substituted instead.
>
> This way is a shade more verbose, but it's good solid defensive
> programming practice: the insert will do what it's supposed to
> even if the table schema changes to add/delete/reorder columns.
The problem is when you are inserting >50 columns, it is a pain. The
use of DEFAULT would also allow SERIAL columns to get the proper
nextval(), rather than having specify the nextval() call specifically.
Added to TODO.
-- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026