As you may have guessed the DEFAULT keyword is used to "even" the size of the tuples in the VALUES clause and explicitly asks the RDBMS to replace itself with the currently defined default value for the corresponding column.
The RDBMS in question is Postgres (>=11).
The context is we want to insert, in batches, data that comes for a message queue. Data comes in as (flat) JSON documents, but where some keys may be omitted. We'd like to insert the batches without the need to know the server defaults. We don't use the ORM layer, only the core layer (though I don't think that would make any difference).
I attached an example that shows why using the DEFAULT keyword seems useful: it avoids errors or data losses. A short comment explains what's wrong at the top of each case. The example, to be run successfully, assumes a Postgres server is running, accessible through its unix socket, and the current user as access to a default database (generally one which name matches is login name) and can create a table in the public schema. You can change the server address if need be (see l. 48), change the schema (l. 42) or table name (l. 36).
The important thing in the previous example was that we have tuples of different sizes: a 3-tuple and a 2-tuple (when DEFAULT is omitted). Something that, if fed as is to your SQL server, it will probably choke on: (1,'one', 'I') and (1000000, 'one million'). If I do what you suggest (omit the roman column) then I cannot pass an explicit value for that column when I have one.
A detail I forgot in the previous message is that the `roman` column in the `numbers` table is not nullable.
roman STRING DEFAULT 'inexpressible' NOT NULL,
) ;
I mention this because I found old posts that mention in some case tuples may be complete with NULL(s), but that is not what I observed and would not work anyway in our context. You might argue why not drop the NOT NULL and make NULL equivalent to 'inexpressible'. That would make perfect sense, I a perfect world. But assume the database is ages old, hence has lots of quirks I cannot get rid of (yet).
Of course, I may be missing something, probably obvious, that would explain why nobody asked about this before. Hope it is a bit clearer.
Regards,
Nicolas