SQL Tutorial

Learn SQL to create, query and manage relational databases in MySQL, PostgreSQL, Oracle and SQL Server.

SQL (Structured Query Language) is the standard language for working with relational databases. It was developed at IBM in the 1970s (originally called SEQUEL) and standardised by ANSI in 1986 and ISO in 1987.

SQL Command Categories

CategoryCommandsPurpose
DDLCREATE, ALTER, DROP, TRUNCATE, RENAMEDefine structure
DMLINSERT, UPDATE, DELETEChange data
DQLSELECTQuery data
DCLGRANT, REVOKEPermissions
TCLCOMMIT, ROLLBACK, SAVEPOINTTransactions

Your First Query

Most examples use this employees table:

idnamedeptsalarycity
1AshaIT65000Pune
2RaviHR42000Mumbai
3MeeraIT78000Pune
4KaranSales51000Delhi
5NehaHR47000Pune
SQL
SELECT name, salary FROM employees WHERE dept = 'IT';
+-------+--------+ | name | salary | +-------+--------+ | Asha | 65000 | | Meera | 78000 | +-------+--------+
StyleSQL keywords aren't case-sensitive, but writing them in UPPERCASE makes queries easier to read. End each statement with a semicolon.
Track your progress through the SQL course