Skip to content

Instantly share code, notes, and snippets.

@davidbella
Created September 25, 2013 03:55
Show Gist options
  • Save davidbella/6695007 to your computer and use it in GitHub Desktop.
Save davidbella/6695007 to your computer and use it in GitHub Desktop.
SQL: Simple create, alter, and drop tables
CREATE TABLE artists(
name TEXT,
album_count INTEGER,
song_count INTEGER,
worth_in_mil REAL
);
ALTER TABLE artists ADD COLUMN best_album TEXT;
ALTER TABLE artists ADD COLUMN worst_album TEXT;
-- Can't drop column in SQLite, dropping and recreating table
DROP TABLE artists;
CREATE TABLE artists(
name TEXT,
album_count INTEGER,
song_count INTEGER,
best_album TEXT,
worst_album TEXT
);
ALTER TABLE artists RENAME TO musicians;
DROP TABLE musicians;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment