Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solution for Database Drill: Intro to SQLite
# Solution for Challenge: Database Drill: Intro to SQLite. Started 2015-05-09T04:09:18+00:00
sqlite>
sqlite> .schema
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(64) NOT NULL,
last_name VARCHAR(64) NOT NULL,
email VARCHAR(128) UNIQUE NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL
, nicknames VARCHAR(64) NOT NULL DEFAULT(1));
sqlite> SELECT * FROM users;
sqlite> INSERT INTO users
...> (first_name, last_name, email, created_at, updated_at)
...> VALUES
...> ('Jessie', 'Farmers', 'jesse@devbootcamp.com', DATETIME('now'), DATETIME('now'));
sqlite> .schema
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
first_name VARCHAR(64) NOT NULL,
last_name VARCHAR(64) NOT NULL,
email VARCHAR(128) UNIQUE NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL
, nicknames VARCHAR(64) NOT NULL DEFAULT(1));
sqlite> SELECT * FROM users
...> ;
id first_name last_name email created_at updated_at nicknames
---------- ---------- ---------- --------------------- ------------------- ------------------- ----------
1 Jessie Farmers jesse@devbootcamp.com 2015-05-09 21:15:52 2015-05-09 21:15:52 1
sqlite> UPDATE users
...> SET nicknames = 'Ninja Coder', updated_at = DATETIME('now')
...> WHERE id = 1;
sqlite> SELECT * FROM users
...> ;
id first_name last_name email created_at updated_at nicknames
---------- ---------- ---------- --------------------- ------------------- ------------------- -----------
1 Jessie Farmers jesse@devbootcamp.com 2015-05-09 21:15:52 2015-05-09 21:18:42 Ninja Coder
sqlite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment