Detailed List of SQL Commands

SQL or Structured Query Language is a type of programming language used for managing data stored in relational databases. It is operating through simple and declarative statements. Thus the data will be accurate and secured. In other words, SQL helps to maintain the integrity of the database irrespective of its size.

Below is the list of SQL Commands that are used commonly.

List of SQL Commands

After Table: – This command helps to add a column to a table.

table_name ADD column datatype;

And: – This command is meant for joining two conditions together provided both the conditions are true for the row to be included in the result test.

SELECT column_name(s)
FROM table_name
WHERE column_1 = value_1
AND column_2 = value_2;

As: – This is a key word that permits you to rename a column or a table using some other related names

SELECT column_name AS ‘Alias’
FROM table_name;

AVG: – This is an aggregate function and it will return an average value to a numerical column.

SELECT AVG(column_name)
FROM table_name;

Between: – This command or operator is used to filter the result sets within a specific range. Values can be dates, numbers or texts.

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value_1 AND value_2;

Count: – This will take the name of a column as an argument and will count the number of rows where the column is not NULL.

SELECT COUNT(column_name)
FROM table_name;

Create Table: – This command is used to create a new table in the database. This will also allows to name the table and each columns in the table.

CREATE TABLE table_name (column_1 datatype, column_2 datatype, column_3 datatype);

Delete: – With this command, rows can be removed from the tables.

DELETE FROM table_name WHERE some_column = some_value;

Group By: – This is a clause in SQL that can be used only with aggregate functions. It is usually used with “Select” command to bring in similar data into a group.

SELECT COUNT(*)
FROM table_name
GROUP BY column_name;

Inner Join: – This is used for combining rows from different tables provided the joining condition is true

SELECT column_name(s) FROM table_1
JOIN table_2
ON table_1.column_name = table_2.column_name;

Insert: – This is used for adding a new row to the table.

INSERT INTO table_name (column_1, column_2, column_3) VALUES (value_1, ‘value_2’, value_3);

Like: – It is a special command always used with the command “Where” to find out a specific pattern in the table.

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;

Limit: – This statement helps to specify the maximum number of rows a result set should have.

SELECT column_name(s)
FROM table_name
LIMIT number;

Max: – This function takes the name of the column as an argument and returns the largest value in that specific column.

SELECT MAX(column_name)
FROM table_name;

Min: – This function takes the name of the column as an argument and returns the smallest value in that specific column.

SELECT MIN(column_name)
FROM table_name;

Or: – This function filters the result set to includes rows where either of the given conditions is true.

SELECT column_name
FROM table_name
WHERE column_name = value_1
OR column_name = value_2;

Ordered By: – This indicates that you are planning to sort the result by a specific column either alphabetically or numerically.

SELECT column_name
FROM table_name
ORDER BY column_name ASC|DESC;

Outer Join: – This will join rows from different tables even if the conditions are not true.

SELECT column_name(s) FROM table_1
LEFT JOIN table_2
ON table_1.column_name = table_2.column_name;

Round: – This function will take a column name and an inter as an argument and round up the values in the column to the number of decimal places specified by the integer.

SELECT ROUND(column_name, integer)
FROM table_name;

Select: – This is used to get data from the database. Every query will be start with this command.

SELECT column_name FROM table_name;

Select Distinct: – This is a query that returns a specific unique value in the column or columns.

SELECT DISTINCT column_name FROM table_name;

Sum: – This will take the name of a column as an argument and returns the sum of all values in that column.

SELECT SUM(column_name)
FROM table_name;

Update: – This is used to edit the rows in a table.

UPDATE table_name
SET some_column = some_value
WHERE some_column = some_value;

Where: – This indicates that you want to filter the result set to include only the rows which meet the conditions.

SELECT column_name(s)
FROM table_name
WHERE column_name operator value;

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *