0% found this document useful (0 votes)
2 views

SQL – Creating and Opening Database

The document explains SQL commands related to creating and managing databases, including the CREATE DATABASE statement for establishing new databases and the SHOW DATABASES command for listing existing ones. It also describes the USE statement for selecting a database and the CREATE DATABASE IF NOT EXISTS command to avoid errors when creating databases that may already exist. Syntax examples are provided for each command to illustrate their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL – Creating and Opening Database

The document explains SQL commands related to creating and managing databases, including the CREATE DATABASE statement for establishing new databases and the SHOW DATABASES command for listing existing ones. It also describes the USE statement for selecting a database and the CREATE DATABASE IF NOT EXISTS command to avoid errors when creating databases that may already exist. Syntax examples are provided for each command to illustrate their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL – Creating and Opening Database

1. What is the purpose of the CREATE DATABASE statement in SQL?

Answer:
The CREATE DATABASE statement in SQL is used to create a new database in a relational
database management system (RDBMS). It establishes a new container for storing data
in the form of tables, views, and other database objects.

Syntax: CREATE DATABASE database_name;


Example: CREATE DATABASE SchoolDB;

2. How can you list all the databases available in an RDBMS?

Answer:
To list all the databases in an RDBMS, you can use the SHOW DATABASES; command. This
command retrieves a list of all databases present in the system.

Syntax: SHOW DATABASES;

3. What is the purpose of the USE statement in SQL?

Answer:
The USE statement in SQL is employed to select a specific database to work with. Once a
database is selected using this command, all subsequent SQL operations will be
performed on that database until another database is selected.

Syntax: USE database_name;


Example: USE SchoolDB;

4. How can you create a database only if it does not already exist?

Answer:
To create a database only if it does not already exist, you can use the CREATE DATABASE
IF NOT EXISTS statement. This prevents errors that would occur if a database with the
specified name already exists.

Syntax: CREATE DATABASE IF NOT EXISTS database_name;


Example: CREATE DATABASE IF NOT EXISTS SchoolDB;

5. What is the significance of the SHOW DATABASES command?

Answer:
The SHOW DATABASES command is used to display a list of all databases present in the
RDBMS. It helps users to see the available databases and verify if a specific database
exists.

Syntax: SHOW DATABASES;

You might also like