SQL homework
1. Write SQL to correction create the OCEAN table as specified below.
2. Write SQL to inset the data into the OCEAN table as give below
OCEAN:
|
Ocean |
AverageDepth |
PercentOfSurface |
|
Pacific |
13740 |
48 |
|
Atlantic |
12254 |
28 |
|
Gulf |
5299 |
1 |
Ocean is the primary key
When finished “SELECT * FROM OCEAN;” should produce a table that looks something like this
3. Write SQL to correction create the BEACH table as specified below.
4. Write SQL to inset the data into the BEACH table as give below
BEACH:
When finished “SELECT * FROM BEACH;” should produce a table that looks something like this
|
Beach |
State |
Ocean |
|
Manele Bay |
Hawaii |
Pacific |
|
Myrtle Beach |
South Carolina |
Atlantic |
|
Nantucket |
Massachusetts |
Atlantic |
|
Clearwater Beach |
Florida |
Gulf |
|
Coronado |
Californa |
Pacific |
Beach is the primary key, ocean is a foreign key, set up a cascade on insert and cascade on delete for the foreign key referential integrity constraint
5. Use an alter table statement to add a constraint that PercentOfSurface must be between 0 and 100.
6. Update the Ocean Column to say “Gulf of Mexico” instead of “Gulf”
7. Write an SQL statement to delete the Nantucket record.
8. Write an SQL Statement to add the column “TravelChannelRating” to the table BEACH.
9. Write the SQL statement to insert the value 1 for Manele Bay, the Value 2 for Myrtle Beach, the Value 5 for Clearmater Beach, and the Value 7 for Coronado (for the column you just created).
10. Write the SQL necessary to drop the Ocean table.