Back to: Structured Query Language (SQL)
How to create a Database
Open MySQL Workbench –> click Schemas –> Query 1 – we will create out first database:
SQL is NOT case sensitive but most developers use the convention of typing SQL keywords in all UPPERCASE and names in lower case. All SQL statements must end with a semi-colon to let MySQL know the statement is complete. Type in:

CREATE DATABASE myDB;
Click the “lightning bolt” icon above the word CREATE to execute this statement. In the output window “Action Output” you will see that the action was successful.
Refresh the Schemas and your new database will appear:

Your newly create database is ready to use.
To use the new new database, right click it and “Set as Default Schema” OR use the SQL statement:
USE myDB;

How to delete a Database
To delete a database using MySQL Workbench, we can either right-click the database and select “Drop Schema…” or type the SQL statement:
DROP DATABASE myDB;

After executing the DROP DATABASE statement, our database is gone.
Since we do need a database for this session, you’ll need to re-create the database myDB and make it the Default Schema.
How to alter a Database
There are two features that are important to know about – one is setting the database to READ-ONLY, the other is enabling encryption.
To set your database to be “read only“:
ALTER DATABASE myDB READ ONLY = 1;
Your database is now READ ONLY, we can’t make changes to the database but we can still access the data within it – try to DROP the database and see what happens.

To disable READ ONLY mode we set READ ONLY to 0:
ALTER DATABASE myDB READ ONLY = 0;