SQL Keyword

What Is Keyword?

A Keyword is a word reserved for any platform. This word is used to perform various operations. We can't use Keyword as any variable name.

A reserved word called a "keyword" is one that a computer uses exclusively to refer to certain commands or arguments.

SQL Keyword

SQL has also its many reserved keywords. SQL has case insesitive langauge. so it doesn't matter how we write syntax whether in UPPER case or LOWER case.

The following SQL keywords are those that we examine in detail.

1) ADD

The ADD keyword or command is used to add a column to an existing table.

We have to create a table and then realize that we have to add more columns to the table.

So, using the Add keyword, we can add a new column in a table without affecting the existing data in the table.

Click here for more information on ADD keyword.

2) ADD CONSTRAINT

The ADD CONSTRAINT keyword or command is used to add a constraint to an existing column.

We create a table and then realise that we have forgotten to add constraint in a specific column then Add Constraint Command is used.

The ADD CONSTRAINT is a combination of two keywords ADD and CONSTRAINT. they both are different keywords.

But whenever we have to create a constraint to an existing column we use ADD CONSTRAINT keyword.

Click here for more information on ADD CONSTRAINT keyword.

3) ALL

The ALL keyword or command is used to check logical conditions.

The ALL Keyword is a logical operator that compares single value with a single-column set of values returned by a subquery.

The ALL command returns the boolean value True Or False.

Return True if all of the subquery values match the condition.

Click here for more information on ALL keyword.

4) ALTER

The Alter keyword is used when we want to modify something.

If we want to add a new column or delete any column, or if we want to change any procedure, or change any function, The alter command is used in all of the preceding scenarios.

The Alter command is used with another command like 'Alter Table', 'Alter Procedure', 'Alter Column', 'Alter Trigger', etc.

Click here for more information on ALTER keyword.

5) AND

The AND keyword, or operator, is used with the where clause when we want to check multiple conditions and want them to all be true.

The AND operators are used to filter records based on more than one condition and need all conditions to be true.

Click here for more information on AND keyword.

6) ANY

The ANY keyword or command is used to check logical conditions.

The ANY Keyword is logical operator that compares a single value with a single-column set of values returned by a subquery.

The ANY command returns boolean value True Or False.

Return True if any of the subquery value match the condition.

Click here for more information on ANY keyword.

7) ASC

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

We have specified the column sort order using the ASC keyword.

Click here for more information on ASC keyword.

8) BACKUP DATABASE

The Backup Database keyword is used to take or create a full backup of an existing SQL database.

A Database Backup is a copy of SQL Server data that can be used to restore and recover the data after a failure.

We can take multiple backup copies of one database at different times.

A backup file is stored with .bak extension.

Click here for more information on BACKUP DATABASE keyword.

9) BETWEEN

The Between keyword is used to specify the range of values. It means selecting values within a given range.

Using the Between keyword, we can define a range like Start To End. In Range Start and End, both values are included.

The between keyword is used in numbers, dates, or in text values.

For example, between 10 and 20.

Click here for more information on BETWEEN keyword.

10) CASE

The CASE keyword is used to check different conditions and, based on those, give an output.

A case is very useful when we want to give an output based on multiple conditions.

Case is equivalent to if...else if...else.

If all conditions become false, then the part will be executed.

Check multiple conditions and returns a value when the specified condition is met.

We can use case statements in select queries, where clauses, order by clauses, etc.

Click here for more information on CASE keyword.

11) CHECK

The CHECK keyword or constraint is used to limit the value that can be inserted in a column.

Click here for more information on CHECK keyword.

12) COLUMN

The column keyword is used when we want to modify any column or delete any column.

Click here for more information on COLUMN keyword.

13) CONSTRAINT

The Constraints are the rules that we can apply on the type of data in a table. like not null, unique, check the limit, primary, etc.

Click here for more information on CONSTRAINT keyword.

14) CREATE

The create keyword is used to create tables, databases, views, procedures, indexes, functions, etc.

Click here for more information on CREATE keyword.

15) DEFAULT

The DEFAULT keyword or constraint is used to give the default value in a column.

If the value is entered by the user, we sometimes do not enter the value at that moment if we want to add a default value in the column. So, in that case, Default Constraints are used.

Click here for more information on DEFAULT keyword.

16) DELETE

A table's existing records can be deleted using the DELETE command.

17) DESC

The DESC keyword or command is used to sort the data in descending order.

We have specified the column sort order using the DESC keyword.

Click here for more information on DESC keyword.

18) DISTINCT

The SELECT DISTINCT statement is used for returning only distinct (different) values from a column.

Click here for more information on DISTINCT keyword.

19) DROP

The Drop keyword is used to delete existing tables, databases, views, indexes, etc.

The Drop keyword is also used to delete an existing column or constraints from a table.

Click here for more information on DROP keyword.

20) EXEC

The Exec keyword is used to execute a stored procedure.

When you want to run any stored procedure, the execute keyword is used.

Click here for more information on EXEC keyword.

21) EXISTS

The EXISTS keyword is used to check the existence of any record in a subquery, returning true if the record exists and false if the record does not exist.

Click here for more information on EXISTS keyword.

22) FOREIGN KEY

The Foreign Key Constraints is used to link two tables together.

The foreign key from one table is linked to the primary key from another table.

Click here for more information on FOREIGN KEY keyword.

23) FROM

To indicate which table to pick or delete data from, use the FROM command.

24) FULL OUTER JOIN

The Full Outer Join Keyword is used to combine two tables and returns all matching records from both tables, whether the other table matches or not.

Click here for more information on FULL OUTER JOIN keyword.

25) GROUP BY

The Group By keyword is used to arrange identical data into groups using aggregate functions like COUNT, MAX, MIN, SUM, AVG.

We can group the data by using one or more columns.

Group By Clause is used with the Select query.

Group By Clause comes after the Where Clause but before the Order By Clause. 

Click here for more information on GROUP BY keyword.

26) HAVING

The Having keyword is used to apply a filter to the group by clause result.

The where clause is not applicable in the aggregate result, so the having clause is introduced.

The Having clause is used after the group by clause.

The Having clause is used with select queries.

Click here for more information on HAVING keyword.

27) IN

The IN keyword is used to check multiple values in a where clause.

When you want to give a condition based on multiple values, then the In Operator is used.

The IN operators behave the same as the OR operators.

Click here for more information on IN keyword.

28) INDEX

The INDEX keyword is used to add or remove indexes from tables. Indexes are used to quickly retrieve data from databases.

The indexes are only used to speed up searches and queries; users cannot see them.

29) INNER JOIN

The INNER JOIN keyword is used to combine two tables based on a common column, and select records that have matching values in these columns.

In the inner join query, each row of Table 1 is compared with each row of Table 2 based on the join condition. If the condition is met, the column values from both tables are combined to form a single row. 

Click here for more information on INNER JOIN keyword.

30) INSERT INTO

The Insert Into keyword is used to add a new row to a table.

Click here for more information on INSERT INTO keyword.

31) IS NULL

The IS NULL keyword is used to test for empty values (NULL values) in a column.

Click here for more information on IS NULL keyword.

32) JOIN

The JOIN keyword is used to combine two tables based on a common column, and select records that have matching values in these columns.

33) LEFT JOIN

The LEFT JOIN keyword is used to combine two tables and returns all records from the left tables and only matching records from the right tables.

Click here for more information on LEFT JOIN keyword.

34) LIKE

The LIKE keyword is used in the where clause to match the specified pattern in the column.

There are two wildcard characters that are used with a like clause.

  1. % - Represent Zero, One Or More Characters.
  2. _ - Represent only one character

Click here for more information on LIKE keyword.

35) LIMIT, SELECT TOP And ROWNUM

The LIMIT, SELECT TOP, and ROWNUM keywords are used to specify the number of rows to return.

The Limit keyword is used in MySql, Select Top Keyword is used in SQL Server, and the Rownum keyword is used in Oracle.

Click here for more information on LIMIT, SELECT TOP And ROWNUM keyword.

36) NOT

The NOT keyword is used to check if a condition is not true.

The NOT keyword is used with the where clause and returns only those rows where the condition is not true.

Click here for more information on NOT keyword.

37) NOT NULL

The NOT NULL keyword or constraint is used to ensure that no null values are allowed in a column.

If NOT NULL constraints are applied to that column, you cannot insert or update it without adding value. 

Click here for more information on NOT NULL keyword.

38) OR

The OR keyword/operator is used with the where clause when we want to check multiple conditions and want any of them to be true.

The OR operators are used to filter records based on more than one condition and need any of the conditions to be true.

Click here for more information on OR keyword.

39) ORDER BY

The Order By keyword or command is used to sort the data in ascending or descending order.

Click here for more information on ORDER BY keyword.

40) PRIMARY KEY

Every row in a table is given a special identification by the PRIMARY KEY constraint.

A table can have only one primary key, which can be made up of one or more fields.

Click here for more information on PRIMARY KEY keyword.

41) RIGHT JOIN

The RIGHT JOIN keyword is used to combine two tables and returns all records from the right tables and only matching records from the left tables.

Click here for more information on RIGHT JOIN keyword.

42) SELECT

You can choose data from a database using the SELECT command. The information returned is kept in a result table known as the result set.

Click here for more information on SELECT keyword.

43) SET

To define which columns and values to be modified in a table, use the SET command along with the UPDATE command.

Click here for more information on SET keyword.

44) UNIQUE

The UNIQUE keyword or constraint is used to ensure that all values in a column are unique.

Click here for more information on UNIQUE keyword.

45) UNION And UNION ALL

The result set from two or more SELECT operations is combined by the UNION command but only distinct values.

The result set from two or more SELECT operations is combined by the UNION ALL command, and it also allows duplicate values.

Click here for more information on UNION And UNION ALL keyword.

46) UPDATE

The Update keyword is used to update the values of an existing row in a table.

Click here for more information on UPDATE keyword.

Summary

Here we learn about all the SQL keywords.

SQL uses reserved keywords for database operations.


Recommended Ebook

Basic SQL Queries

Download Now!
Similar Articles