0

The docs specify two alternatives: insert values or insert default values (https://www.sqlite.org/lang_insert.html)

The trouble is if one for example has a 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 into values(?, ?, ?, ?, ?, ?) since it expects rowid and country to be specified. Is there a shortcut for specifying insert into values with default values populating the default fields? Or is impossible without explicitly naming all the non-default fields?

1 Answer 1

1

Yes, it is impossible. In any event it is good practice to explicitly name the columns you are INSERTing into anyway -- leaving the columns out leads to more fragile code and more "silent failure" possibilities in which you're not inserting data into the column you think you are inserting it into.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.