Created
September 25, 2013 03:55
-
-
Save davidbella/6695007 to your computer and use it in GitHub Desktop.
SQL: Simple create, alter, and drop tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE artists( | |
name TEXT, | |
album_count INTEGER, | |
song_count INTEGER, | |
worth_in_mil REAL | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE artists ADD COLUMN best_album TEXT; | |
ALTER TABLE artists ADD COLUMN worst_album TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE artists RENAME TO musicians; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE musicians; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment