Learning of SQL Day 3

 

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:

  1. Creating a Database:

    • The CREATE DATABASE statement is used to create a new database.

sql
-- Create a new database named UniversityDB
CREATE DATABASE UniversityDB;
  1. Checking the Existing Databases:

    • Use the SHOW DATABASES statement to list all databases.

sql
-- Show all databases
SHOW DATABASES;
  1. Dropping a Database:

    • The DROP DATABASE statement is used to delete a database.

sql
-- Drop the database named UniversityDB
DROP DATABASE UniversityDB;

Practice Exercise:

  1. Create a new database named LibraryDB.

  2. Verify that the database is created by listing all databases.

  3. Drop the LibraryDB database.

  4. 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.

Post a Comment

0 Comments