Day 3: Creating and Dropping Databases
Introduction:
Managing databases is a crucial aspect of SQL. Today, we will focus on creating and dropping databases.
Key Concepts:
Database Creation: Set up a new database.
Database Deletion: Remove an existing database.
SQL Commands:
Creating a Database:
The
CREATE DATABASEstatement is used to create a new database.
-- Create a new database named UniversityDB
CREATE DATABASE UniversityDB;
Checking the Existing Databases:
Use the
SHOW DATABASESstatement to list all databases.
-- Show all databases
SHOW DATABASES;
Dropping a Database:
The
DROP DATABASEstatement is used to delete a database.
-- Drop the database named UniversityDB
DROP DATABASE UniversityDB;
Practice Exercise:
Create a new database named
LibraryDB.Verify that the database is created by listing all databases.
Drop the
LibraryDBdatabase.Verify that the database is dropped by listing all databases again.
Important Tips:
Always ensure that you are not dropping a database that contains important data.
Use database names that are meaningful and relevant to the project.
This will solidify your understanding of creating and managing databases.
0 Comments