0
0
MySQLquery~5 mins

Database creation and selection in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the SQL command to create a new database named 'library'?
The command is CREATE DATABASE library;. This creates a new empty database called 'library'.
Click to reveal answer
beginner
How do you select a database named 'library' to use it for your queries?
Use the command USE library;. This tells the system to work with the 'library' database for following commands.
Click to reveal answer
intermediate
What happens if you try to create a database that already exists without using any extra options?
You will get an error saying the database already exists. To avoid this, use CREATE DATABASE IF NOT EXISTS database_name;.
Click to reveal answer
beginner
Why is it important to select a database before running queries?
Selecting a database tells the system where to look for tables and data. Without selecting, queries may fail or run on the wrong database.
Click to reveal answer
beginner
Write the SQL commands to create a database named 'school' and then select it for use.
First, create the database: CREATE DATABASE school;<br>Then select it: USE school;
Click to reveal answer
Which SQL command creates a new database?
ACREATE DATABASE database_name;
BSELECT DATABASE database_name;
CUSE database_name;
DDROP DATABASE database_name;
How do you tell MySQL to use a specific database for your queries?
AUSE database_name;
BCREATE DATABASE database_name;
CSELECT * FROM database_name;
DDROP DATABASE database_name;
What will happen if you run CREATE DATABASE test; when 'test' already exists?
AIt will overwrite the existing database.
BIt will create a new database with a different name.
CIt will give an error.
DIt will delete the existing database.
Which command prevents an error if the database already exists when creating it?
ADROP DATABASE database_name;
BCREATE DATABASE database_name;
CUSE database_name;
DCREATE DATABASE IF NOT EXISTS database_name;
Why do you need to select a database before running queries?
ATo delete the database.
BTo tell MySQL which database to work with.
CTo create a new database.
DTo backup the database.
Explain how to create a new database and select it for use in MySQL.
Think about the two steps: making the database and then telling MySQL to use it.
You got /3 concepts.
    What is the purpose of the 'IF NOT EXISTS' clause in database creation?
    It helps avoid errors when the database is already there.
    You got /3 concepts.