Created
September 25, 2013 04:06
-
-
Save loganhasson/6695064 to your computer and use it in GitHub Desktop.
List of SQL commands used to complete sql-book homework
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
/* Part 1 */ | |
CREATE TABLE musicians( | |
name TEXT, | |
age INTEGER, | |
rating REAL, | |
genre TEXT, | |
instrument TEXT | |
); | |
/* Part 2 */ | |
ALTER TABLE musicians ADD COLUMN nationality TEXT; | |
ALTER TABLE musicians ADD COLUMN phone_number INTEGER; | |
ALTER TABLE musicians ADD COLUMN address TEXT; | |
ALTER TABLE musicians ADD COLUMN label TEXT; | |
ALTER TABLE musicians ADD COLUMN number_of_recordings INTEGER; | |
/* Part 3 */ | |
/* first create a copy of the table missing one column (number_of_recordings) */ | |
CREATE TABLE musicians_2( | |
name TEXT, | |
age INTEGER, | |
rating REAL, | |
genre TEXT, | |
instrument TEXT, | |
nationality TEXT, | |
phone_number INTEGER, | |
address TEXT, | |
label TEXT | |
); | |
/* then drop original table */ | |
DROP TABLE musicians; | |
/* finally, rename new table back to "musicians" */ | |
ALTER TABLE musicians_2 RENAME TO musicians; | |
/* Part 4 */ | |
ALTER TABLE musicians RENAME TO artists; | |
/* Part 5 */ | |
DROP TABLE artists; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment