SQL Reference


Welcome to SQL


Our SQL language reference gives you SQL answers quickly.

We cover important SQL concepts and features -- with examples.

Try the SQL examples live in our online SQL Editor.

What is SQL

SQL stands for Structure Query Language.

SQL is a programming language that is used to manage relational databases.

SQL commands retrieve, create, update, and delete data from a database.

Other commands can be used to control and manage the database.

SQL Commands

SQL commands fall into into 5 categories:

  • DQL = Data Query Language
  • DML = Data Manipulation Language
  • TCL = Transaction Control Language
  • DDL = Data Definition Language
  • DCL = Data Control Language

Data Query Language (DQL)


Data Query Language commands are used to retrieve data from the database. This category has only one command, but it is, by far, the most commonly used query.

  • SELECT - retrieves database records

Data Manipulation Language (DML)


Data Manipulation Language commands are used to create, modify or delete data in the database. These commands include:

  • INSERT - adds a single or multiple records in the table
  • UPDATE - modifies an existing record
  • DELETE - removes a record from the database

Transaction Control Language (TCL)


Transaction Control Language commands are used to control database transactions. These commands include:

  • COMMIT - commits a transaction
  • ROLLBACK - undo a transaction
  • SAVE - sets a transaction savepoint

Data Definition Language (DDL)


Data Definition Language commands are used to define and modify database structures. These commands include:

  • CREATE - creates database and other objects (tables, views, indexes, etc.)
  • DROP - deletes database and other objects
  • ALTER - modifies the database structure
  • TRUNCATE - removes all records from a table

Data Control Language (DCL)


Data Control Language commands are used to grant or revoke user rights and permissions. These commands include:

  • GRANT - gives priveleges to a database user
  • REVOKE - removes priveleges from a database user

SQL Process

When SQL Server executes a command, it uses a number of components to interpret the request and determine the optimal way to perform the task. This process includes the following steps:

SQL Process

SQL Server Agent

SQL Server Agent is a service that executes scheduled administrative operations, called jobs, in SQL Server. It is a separate process from the database that can be started and stopped independently.

SQL Server Agent can run a job 1) at a scheduled time, or 2) in response to a certain event, or 3) on demand (i.e. manually).

An example would be backup job that runs every day at 2:00 AM. Before the actual backup operation, perhaps a stored procedure needs to run to ensure that all aggregate data is up-to-date. This can all be part of a single job that consists of one or more tasks.

You may also like

Last updated on Dec 21, 2023