Quick Reference
This is a quick reference list of SQL keywords and how they are used to write SQL statements.
- SQL – ADD KeywordThe ADD keyword is used to add columns or constraints to an existing table.
- SQL – ALL KeywordThe ALL keyword returns true if all of the subquery conditions are met.
- SQL – ALTER KeywordThe ALTER keyword adds, deletes, or modifies columns in a table. It can also add and delete various constraints in a table.
- SQL – AND KeywordThe AND keyword is used with the WHERE keyword to only include rows where both conditions is true.
- SQL – ANY KeywordThe ANY keyword returns true if any of the subquery conditions are met.
- SQL – AS KeywordThe AS keyword is used to output a column or table with a temporary alias for the duration of the query. Nothing in the database itself is altered.
- SQL – ASC KeywordThe ASC keyword is used to sort the returned data in ascending order (A – Z).
- SQL – BACKUP DATABASE KeywordsThe BACKUP DATABASE keywords are used in SQL Server to create a full back up of an existing SQL database.
- SQL – BETWEEN KeywordThe BETWEEN keyword is used to select values (numbers, text, or dates) within a given range (inclusively).
- SQL – CASE KeywordThe CASE keyword is used is to create different output based on various conditions.
- SQL – CHECK KeywordThe CHECK keyword is a constraint that limits the value that can be placed in a column.
- SQL – COLUMN KeywordThe COLUMN keyword is used to change the data type of a column or delete a column in a table.
- SQL – CONSTRAINT KeywordThe CONSTRAINT keyword is used to create or delete a constraint from an existing table.
- SQL – CREATE KeywordThe CREATE keyword is used to create new databases, indexes, procedures, tables, and views.
- SQL – DATABASE KeywordThe DATABASE keyword is used to create a new SQL database or delete an existing SQL database.
- SQL – DEFAULT KeywordThe DEFAULT keyword provides a default value for a column that will be added to all new records if no other value is specified.
- SQL – DELETE KeywordThe DELETE keyword is used to delete existing records in a table.
- SQL – DESC KeywordThe DESC keyword is used to sort the returned data in descending order (Z – A).
- SQL – DISTINCT KeywordThe DISTINCT keyword returns only different values (no two values the same) in the result set.
- SQL – DROP KeywordThe DROP keyword is used to delete existing columns, constraints, databases, indexes, tables, and views.
- SQL – EXEC KeywordThe EXEC keyword is used to execute a stored procedure.
- SQL – EXISTS KeywordThe EXISTS keyword tests for the existence of any record in a subquery, and returns “true” if the subquery returns one or more records.
- SQL – FOREIGN KEY KeywordsThe FOREIGN KEY keywords are a key (a field or fields in one table that refers to the PRIMARY KEY in another table) used to link two tables together.
- SQL – FROM KeywordThe FROM keyword is used to specify which table to select or delete data from.
- SQL – FULL OUTER JOIN KeywordsThe FULL OUTER JOIN keyword returns all rows when there is a match in either the left table or right table.
- SQL – GROUP BY KeywordsThe GROUP BY keywords are used to group the result set (used with aggregate functions: COUNT, MAX, MIN, SUM, AVG).
- SQL – HAVING KeywordThe HAVING keyword is used instead of WHERE with aggregate functions.
- SQL – IN KeywordThe IN keyword allows you to specify multiple values in a WHERE clause, and is shorthand for multiple OR conditions.
- SQL – INDEX KeywordIndexes are used to speed up the retrieval of data (searches/queries) from the database.
- SQL – INNER JOIN KeywordsThe INNER JOIN keywords returns rows that have matching values in both tables.
- SQL – INSERT INTO KeywordsThe INSERT INTO statement is used to insert new records in a table.
- SQL – INSERT INTO SELECT KeywordsThe INSERT INTO SELECT keywords copies data from one table and inserts it into another table.
- SQL – IS NOT NULL KeywordsThe IS NOT NULL keywords are used to test for non-empty values (NOT NULL values).
- SQL – IS NULL KeywordsThe IS NULL keywords are used to test for empty values (NULL values).
- SQL – JOIN KeywordThe JOIN keyword is used in an INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN to return matching rows from two tables.
- SQL – LEFT JOIN KeywordsThe LEFT JOIN keywords return all rows from the left table, and the matching rows from the right table (NULL from the right side if there is no match).
- SQL – LIKE KeywordThe LIKE keyword is used in a WHERE clause to search for a specified pattern in a column. It can use two wildcards: % and _.
- SQL – LIMIT KeywordThe LIMIT keyword is used to specify the number of records to return (MySQL).
- SQL – NOT KeywordThe NOT keyword is used with other SQL keywords to only include rows where a condition is NOT true.
- SQL – NOT NULL KeywordsThe NOT NULL keywords enforces a column to NOT accept NULL values (a record cannot be inserted/updated without adding a value to that field).
- SQL – OR KeywordThe OR keyword is used with the WHERE keyword to include rows where at least one of multiple conditions are true.
- SQL – ORDER BY KeywordsThe ORDER BY keywords are used to sort the result set using a specified column in ascending order (A – Z) or descending (Z – A) order.
- SQL – PRIMARY KEY KeywordsThe PRIMARY KEY keywords uniquely identifies each record in a table, which can have only one primary key consisting of a single field or multiple fields.
- SQL – PROCEDURE KeywordThe PROCEDURE keyword is used with the CREATE keyword to create a stored procedure (prepared SQL code to be reused many times).
- SQL – RIGHT JOIN KeywordsThe RIGHT JOIN keywords returns all rows from the right table, and the matching rows from the left table (NULL from the left side if there is no match).
- SQL – SELECT KeywordThe SELECT keyword is used to select specified data from a database.
- SQL – SELECT INTO KeywordsThe SELECT INTO keywords copies data from one table and inserts it into another table.
- SQL – SET KeywordThe SET keyword is used with UPDATE to specify which columns and values should be updated in a table.
- SQL – TABLE KeywordThe TABLE keyword is used along with CREATE, ALTER, and DROP to manage a database table.
- SQL – TOP KeywordThe TOP keyword is used to specify the number of records to return (SQL Server).
- SQL – TRUNCATE TABLE KeywordsThe TRUNCATE TABLE keywords deletes all the data inside a table, but not the table itself.
- SQL – UNION KeywordThe UNION keyword combines the result set of two or more SELECT statements (returning only distinct values).
- SQL – UNION ALL KeywordsThe UNION ALL keywords combines the result set of two or more SELECT statements (will return duplicate values).
- SQL – UNIQUE KeywordThe UNIQUE keyword ensures that all values in a column are unique.
- SQL – UPDATE KeywordThe UPDATE keyword is used to update existing rows in a table.
- SQL – USE KeywordThe USE keyword specifies the database you intend to work with. The statement is often made when starting work on or switching to a particular database.
- SQL – VALUES KeywordThe VALUES keyword specifies the values in an INSERT INTO statement.
- SQL – VIEW KeywordThe VIEW keyword is used to CREATE a virtual table based on the result set of an SQL statement.
- SQL – WHERE KeywordThe WHERE keyword filters a result set to include only records that fulfill a specified condition or set of conditions.
SQL Notes:
- Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.