xxxxxxxxxx
CREATE TABLE [IF NOT EXISTS] [schema_name].table_name (
column_1 data_type PRIMARY KEY,
column_2 data_type NOT NULL,
column_3 data_type DEFAULT 0,
table_constraints
) [WITHOUT ROWID];
xxxxxxxxxx
// To create tables in SQLite
CREATE TABLE "invoice"
(
id INTEGER PRIMARY KEY,
shipping_address TEXT NOT NULL,
total_cost INTEGER NOT NULL
);
CREATE TABLE "order"
(
id INTEGER PRIMARY KEY,
invoice_id INTEGER NOT NULL,
product_name TEXT NOT NULL,
FOREIGN KEY (invoice_id) REFERENCES invoice (id)
);
xxxxxxxxxx
CREATE TABLE contacts (
contact_id INTEGER PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,CCC
email TEXT NOT NULL UNIQUE,
phone TEXT NOT NULL UNIQUE
);
Code language: SQL (Structured Query Language) (sql)
xxxxxxxxxx
CREATE TABLE [IF NOT EXISTS] [schema_name].table_name (
column_1 data_type PRIMARY KEY,
column_2 data_type NOT NULL,
column_3 data_type DEFAULT 0,
table_constraints
) [WITHOUT ROWID];
Code language: SQL (Structured Query Language) (sql)
xxxxxxxxxx
cmd.CommandText = @"CREATE TABLE cars(id INTEGER PRIMARY KEY,
name TEXT, price INT)";
cmd.ExecuteNonQuery();