Learn more about SQL, a standard language for interacting with databases and storing, manipulating, and retrieving data from databases.
Go hands-on with SQL in our free interactive SQL tutorial.
While the primary construct of SQL is queries, they are actually a special type of command. SQL is composed of many different types of components which make up its syntax.
SQL statements are the fundamental building blocks which make up the language. A SQL statement is a command that will do a unit of “work” and a single statement can be understood and executed by the SQL engine in its entirety.
SQL queries are special types of statements that return data as their result. These are without question the most commonly executed type of SQL statement. As such, you may also hear SQL code referred to in general informally in this way (“send me your queries later”), though an SQL query most often refers specifically to SELECT statements.
SQL clauses are modifying subcomponents which may be added to a SQL statement to alter the behavior of the command and its output. SQL clauses are optional additions to modify a statement, though there are some exceptions where they are essentially mandatory (e.g. you cannot write a SELECT statement to retrieve data from a table without using a FROM clause).
SQL expressions are elements of a SQL statement which evaluate to a scalar (numeric, alphanumeric, or true/false) value or values. They can be used to return specific subsets of data when filtering, or to generate new data, for example, by calculating new values based on formulas or business logic.
Predicates are a special type of expression that result in a boolean – true or false – value (or unknown). They are frequently used for filtering the data returned in queries based upon conditions.
Operators in SQL are used to create expressions by comparing or modifying individual fields or scalar values. For example, arithmetic operators can be used to perform algebra or evaluate whether values in a field are greater or less than a given value or another field at the record level.
Keywords are not a syntactic construct, but words used in the elements of SQL syntax and so should not be used as column or table names or aliases (e.g. SELECT is a reserved keyword indicating the beginning of a statement).
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