A SQL statement is the most fundamental building block of SQL. A statement is a command to be understood by the interpreter and executed by the SQL engine.
SQL statements may do many different types of work in a database: they can return data as the result of a query, modify data or the structure of the tables, delete data or even whole tables, as well as more advanced operations such as updating user permissions or altering the underlying way data are stored and returned from a table.
Broadly speaking, SQL statements fall into four main categories of sub-languages:
- Data Query Language (DQL) Statements, which returns data from tables in the database;
- Data Definition Language (DDL) Statements, which alter or return information on the underlying structure and format of data in a SQL database;
- Data Manipulation Language (DML) Statements, which add, modify, delete, and control access to data;
- Data Control Language (DCL) Statements, which control access rights of users to data and operations within a database
Here we will only look at a selection of the most commonly used SQL statements by a data analyst or data scientist, which are primarily for querying and manipulating data. Statements for data definition and control would be more commonly used by either data engineers or database administrators.
A statement is a whole command to be executed in its entirety. SQL statements furthermore are composed of many different elements which make up the SQL language such as clauses, identifiers, expressions, keywords, and predicates. While knowing the specific details of what constitutes each is not critical, we will see the most commonly used of these in practical examples, as well as covering the most important clauses in a separate section.
Learn SQL Today
Get hands-on experience writing code with interactive tutorials in our free online learning platform.
- Free and fun
- Designed for beginners
- No downloads or setup required