13.8 Practical Exercises
Exercise 1: Creating Databases and Tables
- Create a new database named ExerciseDB.
- In this database, create a table called Customers with the following fields:
- CustomerID (int, primary key)
- FirstName (varchar(255))
- LastName (varchar(255))
- City (varchar(255))
The SQL commands for these tasks would look something like this:
Exercise 2: Inserting Data
- Insert the following records into the Customers table:
- CustomerID = 1, FirstName = 'John', LastName = 'Doe', City = 'New York'
- CustomerID = 2, FirstName = 'Jane', LastName = 'Smith', City = 'London'
Here's what your SQL might look like:
Exercise 3: Updating and Deleting Data
- Update the City of CustomerID = 1 to 'Los Angeles'.
- Delete the record where CustomerID = 2.
Your SQL might look like this:
Exercise 4: Querying Data
- Select all records from the Customers table.
- Select only the FirstName and City...