SQL

SQL (pronounced “ess-que-el”) stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database or retrieve data from a database. Some common relational database management systems that use SQL are Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as “Select”, “Insert”, “Update”, “Delete”, “Create”, and “Drop” can be used to accomplish almost everything that one needs to do with a database.

KeywordDescription
ADDAdds a column in an existing table
ADD CONSTRAINTAdds a constraint after a table is already created
ALTERAdds, deletes, or modifies columns in a table, or changes the data type of a column in a table
ALTER COLUMNChanges the data type of a column in a table
ALTER TABLEAdds, deletes, or modifies columns in a table
ALLReturns true if all of the subquery values meet the condition
ANDOnly includes rows where both conditions is true
ANYReturns true if any of the subquery values meet the condition
ASRenames a column or table with an alias
ASCSorts the result set in ascending order
BACKUP DATABASECreates a back up of an existing database
BETWEENSelects values within a given range
CASECreates different outputs based on conditions
CHECKA constraint that limits the value that can be placed in a column
COLUMNChanges the data type of a column or deletes a column in a table
CONSTRAINTAdds or deletes a constraint
CREATECreates a database, index, view, table, or procedure
CREATE DATABASECreates a new SQL database
CREATE INDEXCreates an index on a table (allows duplicate values)
CREATE OR REPLACE VIEWUpdates a view
CREATE TABLECreates a new table in the database
CREATE PROCEDURECreates a stored procedure
CREATE UNIQUE INDEXCreates a unique index on a table (no duplicate values)
CREATE VIEWCreates a view based on the result set of a SELECT statement
DATABASECreates or deletes an SQL database
DEFAULTA constraint that provides a default value for a column
DELETEDeletes rows from a table
DESCSorts the result set in descending order
DISTINCTSelects only distinct (different) values
DROPDeletes a column, constraint, database, index, table, or view
DROP COLUMNDeletes a column in a table
DROP CONSTRAINTDeletes a UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK constraint
DROP DATABASEDeletes an existing SQL database
DROP DEFAULTDeletes a DEFAULT constraint
DROP INDEXDeletes an index in a table
DROP TABLEDeletes an existing table in the database
DROP VIEWDeletes a view
EXECExecutes a stored procedure
EXISTSTests for the existence of any record in a subquery
FOREIGN KEYA constraint that is a key used to link two tables together
FROMSpecifies which table to select or delete data from
FULL OUTER JOINReturns all rows when there is a match in either left table or right table
GROUP BYGroups the result set (used with aggregate functions: COUNT, MAX, MIN, SUM, AVG)
HAVINGUsed instead of WHERE with aggregate functions
INAllows you to specify multiple values in a WHERE clause
INDEXCreates or deletes an index in a table
INNER JOINReturns rows that have matching values in both tables
INSERT INTOInserts new rows in a table
INSERT INTO SELECTCopies data from one table into another table
IS NULLTests for empty values
IS NOT NULLTests for non-empty values
JOINJoins tables
LEFT JOINReturns all rows from the left table, and the matching rows from the right table
LIKESearches for a specified pattern in a column
LIMITSpecifies the number of records to return in the result set
NOTOnly includes rows where a condition is not true
NOT NULLA constraint that enforces a column to not accept NULL values
ORIncludes rows where either condition is true
ORDER BYSorts the result set in ascending or descending order
OUTER JOINReturns all rows when there is a match in either left table or right table
PRIMARY KEYA constraint that uniquely identifies each record in a database table
PROCEDUREA stored procedure
RIGHT JOINReturns all rows from the right table, and the matching rows from the left table
ROWNUMSpecifies the number of records to return in the result set
SELECTSelects data from a database
SELECT DISTINCTSelects only distinct (different) values
SELECT INTOCopies data from one table into a new table
SELECT TOPSpecifies the number of records to return in the result set
SETSpecifies which columns and values that should be updated in a table
TABLECreates a table, or adds, deletes, or modifies columns in a table, or deletes a table or data inside a table
TOPSpecifies the number of records to return in the result set
TRUNCATE TABLEDeletes the data inside a table, but not the table itself
UNIONCombines the result set of two or more SELECT statements (only distinct values)
UNION ALLCombines the result set of two or more SELECT statements (allows duplicate values)
UNIQUEA constraint that ensures that all values in a column are unique
UPDATEUpdates existing rows in a table
VALUESSpecifies the values of an INSERT INTO statement
VIEWCreates, updates, or deletes a view
WHEREFilters a result set to include only records that fulfill a specified condition

Ad

Be the first to comment

Leave a Reply

Your email address will not be published.