Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

-->Overview of SQL statements:-(SQL LANGUAGES)

1.DDL:- DATA DEFINITION LANGUAGE


2.DML:- DATA MANIPULATION LANGUAGE
3.TCL:-TRANSACTION CONTROL LANGUAGE
4.DCL:- DATA CONTROL LANGUAGE
5.DQL:- DATA QUERY LANGUAGE OR
DRL:- DATA RETRIVAL LANGUAGE

5.DQL:- DATA QUERY LANGUAGE:-

*It is used to retrieve or fetch the data from the database.

-->DQL SUB STATEMENTS:-/(types of DQL Statements):-

a) SELECT
b) PROJECTION
c) SELECTION
d) JOINS

a) SELECT:-
*It is a keyword
*It is the process of retrieving or fetching the data from the table and to
display.

b) PROJECTION:-
*It is the process of retrieving or fetching the data from the table by selection
only the column.

c) SELECTION:-
*It is the process of retrieving or fetching the data from the table by selection
both rows and column.

d) JOINS:-
*It is the process of fetching or retrieving the data from multiple tables
symultaniously.

-->PROJECTION:-
*It is the process of retrieving or fetching the data from the table by selection
only the column.

SYNTAX:-(WITH 2-CLAUSES)

SELECT */[DISTINCT],COLUMN_NAME/EXPRESSION,[ALIAS]->ARGUEMENTS
FROM TABLE_NAME;

-->ORDER OF EXECUTION:-

1st FROM CLAUSE


2nd SELECT CLAUSE

-->FROM CLAUSE:-

*It will execute first.


*The job of FROM CLAUSE is to go to the database, search for table, and put that
table under execution.
*In FROM CLAUSE, we can give TAB_NAME as an arguement.

-->SELECT CLAUSE:-
*It executes after the execution of FROM CLAUSE.
*In SELECT CLAUSE we can give COL_NAME/EXP as an arguement.
*The job of the SELECT CLAUSE is to go the table which is under execution, and
display the records or COl_NAME/EXP mentioned.

-----------------------------------------------------------------------------------
----
-->ASTRISIKS:-

* It is a star used to display all the records/details from the perticular table.

-->SET PAGES 100 LINES 100:-

*It is a command which is used to set the pages as well as lines.

-->SEMI COLEAN:-

*It is used to terminate/end the query.

--> DISTINCT:-

*It is a command used to remove the repeated or duplicated values in the result
table.
*DISTINCT is always used as a first arguement in select clause before using any
other column name.
EX:- SELECT DISTINCT JOB,SAL,ENAME..so on
FROM EMP;
-----------------------------------------------------------------------------------
-----
-->EXPRESSION:-

5+3=8-->EXPRESSION

5+3--> statement
8--> is a result
+-->operator
5 & 3 --> operant

*Any statements which gives results is called as EXPRESSION


*The statements consisits of two arguments
a) operator
ex:- +-->operator
b) operant
ex:- 5 & 3 --> operant

1) WAQTD DETAILS OF THE EMPLOYEES ALONG WITH THEIR ANNUAL SALARY.

a) SELECT *,SAL*12
FROM EMP;

.'. Along with Astrisiks (*), it cannot accept any other column names.
* To overcome this, USE EMP.*, then it accepts any other column names

b) SELECT EMP.*,SAL*12,SAL,JOB..
FROM EMP;

-->ALIAS:-
*It is the alternate name given to the column.
*We can use Alias name without using ALIAS(AS) keyword.
*By 3-ways we can use ALIAS/ALIASING
EX:- SAL*12 as ANNUAL SALARY

a)Without Space-->ANNUALSALARY
b)With Space(BUT WITH DOUBLE COATED)--> "ANNAUL SALARY"
c)With underscore--> ANNUAL_SALARY

EX:-
SELECT EMP.*,SAL*12 ANNUALSAL or "ANNAUL SALARY" or ANNUAL_SALARY
FROM EMP;
-----------------------------------------------------------------------------------
---------------------

-->SELECTION:-

*It is the process of retrieve or fetch the data from the table, by selectiong both
rows and columns.

SYNTAX:-

SELECT COL_NAME/EXP
FROM TABLE_NAME
WHERE FILTER_CONDITION;

-->ORDER OF EXECUTION:-

1ST-FROM CLAUSE
2ND-WHERE CLAUSE
3RD-SELECT CLAUSE

-->WHERE CLAUSE:-

*It is used to Filter the conditions.


*It executes after the execution of from clause.
*It executes row by row
*In where clause, we can write conditions
*And also, we can write multiple conditions, with the help of "Logical Operators".
*Logical Operators->(AND,OR,NOT).
-----------------------------------------------------------------------------------
----------------
-->OPERATORS IN SQL:-(7-operators)

*1.Arithmatic Operator(+,-,/,*)
2.Concatenation Operator (||)
3.Comparission Operator (=,!= or <> )
*4.Relational Operator (<,>,>=,<= )
*5.Logical Operators (AND, OR, NOT )
*6.Special Operator (IN,NOT IN,BETWEEN,NOT BETWEEN,IS,IS NOT,LIKE,NOT LIKE)
7.Sub Query Operator (ALL,ANY,EXISTS,NOT EXISTS)

2.Concatenation Operator (||):-


* It is used to merge/join/combine two Strings.

5.Logical Operators (AND, OR, NOT ):-

* It is used to write multiple conditions inside the WHERE CLAUSE


* We have three types of Logical operators
a) AND b) OR c) NOT

a) AND OPERATOR:-
*It returns true, if all the conditions are satisfied.

b) OR OPERATOR:-
*It returns true, if any one of the conditions are satisfied.

c) NOT OPERATOR:-

*It is a Inverse Operator.


*The select values will gets rejected.

-----------------------------------------------------------------------------------
----------------

You might also like