Commands

SQL, Structured Query Language, is a programming language designed to manage data stored in relational databases. SQL operates through simple, declarative statements. This keeps data accurate and secure, and it helps maintain the integrity of databases, regardless of size.

Here’s an appendix of commonly used commands.

Commands

ALTER TABLE
Adds, deletes, modifies or changes the data type of a column in a table.
AS
Renames a column or table with an alias for display, does not permanently change table/column names in the database.
CASE
A logical test that creates different output based on the conditions of each CASE statement, closes with an END clause.
CREATE TABLE
Creates a new table within a database.
DELETE
Removes existing record(s) from a table. If a WHERE statement is excluded, all records in the table will be deleted.
GROUP BY
Groups a result set based on an aggregate function (COUNT(), MIN(), MAX(), SUM(), AVG()). It lists the number in each group.
HAVING
A conditional statement similar to WHERE but used with aggregate functions (COUNT(), MIN(), MAX(), SUM(), AVG()).
INNER JOIN
Returns a result set of all rows that have matching values in both tables, omits rows where match fails.
INSERT
Inserts new rows into a table.
LIMIT
Specifies, or limits, the maximum number of rows the result set will have.
ORDER BY
Sorts the result set by a particular column either alphabetically or numerically.
OUTER JOIN
Combine rows from different tables even if the join condition is not met.
SELECT
Fetches data from a database. Every query will begin with SELECT.
SELECT DISTINCT
Returns unique values in the specified column(s).
UPDATE
Edits row(s) in a table.
WHERE
Filters records (rows) that match a certain condition.
WITH
Stores the result of a query in a temporary table using an alias.
Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn SQL on Codecademy

Edit this page on GitHub

Contributors