sql - sqlite insert with default values for default fields -
the docs specify 2 alternatives: insert values
or insert default values
(https://www.sqlite.org/lang_insert.html)
the trouble if 1 example has table:
create table address_book values( rowid integer primary key, first_name, last_name, address, phone_number, email, notes, country text default 'usa' )
one can no longer write insert values(?, ?, ?, ?, ?, ?)
since expects rowid
, country
specified. there shortcut specifying insert values
default values populating default fields? or impossible without explicitly naming non-default fields?
yes, impossible. in event practice explicitly name columns insert
ing anyway -- leaving columns out leads more fragile code , more "silent failure" possibilities in you're not inserting data column think inserting into.
Comments
Post a Comment