SQL ASC Keyword

ASC

The ASC command is used to sort the data returned in ascending order.

The following SQL statement selects all the columns from the “Customers” table, sorted by the “CustomerName” column: Continue reading SQL ASC Keyword

SQL AS Keyword

AS

The AS command is used to rename a column or table with an alias.

An alias only exists for the duration of the query.

Alias for Columns

The following SQL statement creates two aliases, one for the CustomerID column and one for the CustomerName column: Continue reading SQL AS Keyword

SQL ANY Keyword

ANY

The ANY command returns true if any of the subquery values meet the condition.

The following SQL statement returns TRUE and lists the productnames if it finds ANY records in the OrderDetails table where quantity = 10: Continue reading SQL ANY Keyword

SQL AND Keyword

AND

The AND command is used with WHERE to only include rows where both conditions is true.

The following SQL statement selects all fields from “Customers” where country is “Germany” AND city is “Berlin”: Continue reading SQL AND Keyword

SQL ALTER TABLE Keyword

ALTER TABLE

The ALTER TABLE command adds, deletes, or modifies columns in a table.

The ALTER TABLE command also adds and deletes various constraints in a table.

The following SQL adds an “Email” column to the “Customers” table: Continue reading SQL ALTER TABLE Keyword

SQL ALTER COLUMN Keyword

ALTER COLUMN

The ALTER COLUMN command is used to change the data type of a column in a table.

The following SQL changes the data type of the column named “BirthDate” in the “Employees” table to type year: Continue reading SQL ALTER COLUMN Keyword

SQL ALTER Keyword

ALTER TABLE

The ALTER TABLE command adds, deletes, or modifies columns in a table.

The ALTER TABLE command also adds and deletes various constraints in a table.

The following SQL adds an “Email” column to the “Customers” table: Continue reading SQL ALTER Keyword

SQL ALL Keyword

ALL

The ALL command returns true if all of the subquery values meet the condition.

The following SQL statement returns TRUE and lists the productnames if ALL the records in the OrderDetails table has quantity = 10: Continue reading SQL ALL Keyword

SQL ADD CONSTRAINT Keyword

ADD CONSTRAINT

The ADD CONSTRAINT command is used to create a constraint after a table is already created.

The following SQL adds a constraint named “PK_Person” that is a PRIMARY KEY constraint on multiple columns (ID and LastName): Continue reading SQL ADD CONSTRAINT Keyword