Nearby lessons
27 of 37JDBC - Create Database
📌 What You Will Learn
- Create a MySQL database with SQL
- Learn the CREATE DATABASE syntax
- Know how to select a database before working on it
Create your first MySQL database — the CREATE DATABASE statement, the USE command, and how the database name appears in your JDBC connection URL.
What is a Database?
Before you can store data with JDBC, a database must exist on your MySQL server. A database is a container that holds tables — and each table holds rows of related data (like employees, products or orders).
In simple words: a database is a folder on the server, and tables are the files inside it.
CREATE DATABASE Syntax
One line of SQL creates a database:
Example02
USE — Pick the Database
Creating the database does not switch to it. Tell MySQL which database you want to work in:
Example03
The Database in the JDBC URL
In JDBC you do not use USE — the database name goes straight into the connection URL:
Example04
Check What Databases Exist
To list every database on the server:
Example05
📝 Key Takeaways
- CREATE DATABASE makes a new, empty database
- USE picks the database for the rest of your session
- In JDBC, the database name goes inside the connection URL