Sei sulla pagina 1di 2

The Data Definition Language (DDL) is used to manage table and index structure.

CREATE, ALTER, RENAME, DROP and TRUNCATE statements are the names of few data
definition elements.

ometimes we need to change the data type of a column. To do this, we use the ALTER
TABLE Modify Column command.

Correct order of SELECT, FROM and WHERE clause is as follow:


SELECT column_name1, column_name2, ....
FROM table_name
WHERE condition

SQL has several arithmetic functions to do math on the numbers, such as summing up,
taking average, retrieved from the column. They are:
AVG():- Average of the column
COUNT():- Number of records
MAX():- maximum of the column
MIN():- minimum of the column
SUM():- Sum of the column

LIKE Operator Description


WHERE CustomerName LIKE 'a%' Finds any values that start with "a"
WHERE CustomerName LIKE '%a' Finds any values that end with "a"
WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the second position
WHERE CustomerName LIKE 'a_%_%' Finds any values that start with "a" and are at
least 3 characters in length

The IN operator allows you to specify multiple values in a WHERE clause.

The IN operator is a shorthand for multiple OR conditions.


SELECT * FROM Customers
WHERE Country IN ('Germany', 'France', 'UK');

The HAVING clause was added to SQL because the WHERE keyword could not be used with
aggregate functions
The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN,
SUM, AVG) to group the result-set by one or more columns.

SELECT A.id
FROM A
WHERE A.age > ALL (SELECT B.age
FROM B
WHERE B. name = "arun")
The meaning of �ALL� is the A.Age should be greater than all the values returned by
the subquery. There is no entry with name �arun� in table B. So the subquery will
return NULL. If a subquery returns NULL, then the condition becomes true for all
rows of A (See this for details). So all rows of table A are selected.

the ANY and ALL operators are used with a WHERE or HAVING clause.
The ANY operator returns true if any of the subquery values meet the condition.
(���� ����� ��� ��� ������ �� �� ��� �� ���� ��� ����� ���� ��� ����� ��� ���� ����
�� �� ���� ��� ����� ��� �� ���� ���� ���� �� �� �����
SELECT ProductName
FROM Products
WHERE ProductID = all (SELECT ProductID FROM OrderDetails WHERE Quantity = 10);
The ALL operator returns true if all of the subquery values meet the condition.

https://www.edufever.com/mcq-on-dbms/

Potrebbero piacerti anche