Show Menu
Cheatography

sqlite3 for SIE377 Cheat Sheet (DRAFT) by

Cheatsheet for sqlite3

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basics

sqlite
Will create a new
filena­me.db
database
 

Alter Tables

The ALTER TABLE function is limited in SQLite
You can either rename the table with: ALTER TABLE tablename RENAME TO newtab­lename
Or add a new column with: ALTER TABLE tablename ADD COLUMN column­def­intion
It is not possible to change column defini­tions of existing tables.
 

Constr­aints

PRIMARY KEY
Sets column as primary key. The constr­aints NOT NULL and UNIQUE will be set automa­tically
NOT NULL
Prevents the column from empty values (null).
UNIQUE
Each value in the column has to be unique.