SQL Commands Reference
Data Definition Language (DDL)
• CREATE DATABASE – creates a new database
• CREATE TABLE – creates a new table
• ALTER TABLE – modifies an existing table
• DROP TABLE – deletes a table
• TRUNCATE TABLE – removes all records from a table
• RENAME – renames a database object
Data Manipulation Language (DML)
• SELECT – retrieves data from the database
• INSERT – inserts data into a table
• UPDATE – updates existing records
• DELETE – deletes records from a table
• MERGE – upserts data (insert or update)
Transaction Control Language (TCL)
• COMMIT – saves the changes permanently
• ROLLBACK – undoes changes since the last COMMIT
• SAVEPOINT – sets a point within a transaction
• SET TRANSACTION – sets transaction properties
Data Control Language (DCL)
• GRANT – gives user access privileges
• REVOKE – removes user access privileges
Other Useful Commands
• CREATE INDEX – creates an index for faster search
• DROP INDEX – deletes an index
• EXPLAIN – shows query execution plan
• DESCRIBE – shows table structure
• SHOW DATABASES – lists all databases
• SHOW TABLES – lists tables in a database
• USE – selects a database to work with