Lesson 3 / 30
Databases vs Tables
Create databases, switch between them with USE and see how one server hosts many databases of tables.
Creating & selecting a database
A database is a named container for tables. USE switches your active database.
CREATE DATABASE shop;
USE shop;
SHOW TABLES;
Output:
Empty set (0.00 sec)
One server, many databases
A single MySQL server commonly hosts several databases — one per application — each isolated with its own set of tables.
Quick check: What does `USE shop;` do?
- Creates a new database
- Deletes the `shop` database
- Makes `shop` the active database for following queries
- Lists every table in the server
Answer
Makes `shop` the active database for following queries — `USE` just switches context — no data is created or removed.