SQLite - How to set default value for a column?
To set default value for a column in SQLite, use DEFAULT
:
Example: We create a table customers with the default value for store_code
column is store1:
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
store_code TEXT DEFAULT "store1" NOT NULL,
name TEXT
);
Need a good GUI tool for SQLite? Check out TablePlus. It’s native, beautiful, and available for free.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS