CREATE DATABASE, DROP & BACKUP
CREATE DATABASE makes a new empty container for tables. You then USE or connect to that database before creating tables.
CREATE DATABASE — start a new database
CREATE DATABASE makes a new empty container for tables. You then USE or connect to that database before creating tables.
Real-life example: CREATE DATABASE is opening a new filing cabinet labeled 'Springfield High 2026' — empty until you add folders (tables).
CREATE DATABASE school_db;
-- MySQL
USE school_db;
-- PostgreSQL: connect with \c school_db in psqlDROP DATABASE — delete entire database
DROP DATABASE permanently removes the database and all its tables. There is no undo — always backup first.
Real-life example: DROP DATABASE is shredding the whole cabinet — every folder inside goes with it.
-- Danger: removes everything in school_db
DROP DATABASE school_db;BACKUP DATABASE — save a copy
Backups protect against mistakes and hardware failure. SQL Server uses BACKUP DATABASE. MySQL often uses mysqldump from the shell. PostgreSQL uses pg_dump.
Real-life example: BACKUP is photocopying the entire register before exam week — if ink spills, you restore from the copy.
BACKUP DATABASE school_db
TO DISK = 'C:\Backups\school_db.bak';-- MySQL (terminal)
-- mysqldump -u root -p school_db > school_db_backup.sql
-- PostgreSQL (terminal)
-- pg_dump school_db > school_db_backup.sql
-- Restore MySQL
-- mysql -u root -p school_db < school_db_backup.sql