Before knowing how to write queries in SQL it is important to know what the different types of SQL queries that you can write are. The following are the four main categories of SQL queries:
• DRL (Data Retrieval Language)
• DML ( Data Manipulation Language)
• DDL ( Data Definition Language)
• DCL (Data Controlling Language)
There names are just given only for categorization so that you may have a better understanding of SQL queries. DRL contain the queries that are used to retrieve or fetch data from the database, such as SELECT statement. You can fetch data from table in accordance to your requirement. DML means the queries that can manipulate the data such as UPDATE, DELETE and INSERT. Likewise DDL means the queries that help in creating and defining the data object such as Tables, Views, Synonyms and Indexes and these queries include CREATE, ALTER. Whereas DCL contain the queries that are used to create new users and for controlling their access to database. Here is an example of SQL queries:
DRL
SELECT FROM EMP
WHERE EMPNO=7788;
DML
UPDATE EMP
SET SAL=2000
WHERE ENAME='KING';
DELET FROM DEPT
WHERE LOC='DALLAS';
DDL
CREATE TABLE EMP
(EMPNO NUMBER (4), ENAME VARCHAR2(10), JOB VARCHAR2(20));
DCL
CREATE USER SCOTT
IDENTIFIED BY TIGER;
• DRL (Data Retrieval Language)
• DML ( Data Manipulation Language)
• DDL ( Data Definition Language)
• DCL (Data Controlling Language)
There names are just given only for categorization so that you may have a better understanding of SQL queries. DRL contain the queries that are used to retrieve or fetch data from the database, such as SELECT statement. You can fetch data from table in accordance to your requirement. DML means the queries that can manipulate the data such as UPDATE, DELETE and INSERT. Likewise DDL means the queries that help in creating and defining the data object such as Tables, Views, Synonyms and Indexes and these queries include CREATE, ALTER. Whereas DCL contain the queries that are used to create new users and for controlling their access to database. Here is an example of SQL queries:
DRL
SELECT FROM EMP
WHERE EMPNO=7788;
DML
UPDATE EMP
SET SAL=2000
WHERE ENAME='KING';
DELET FROM DEPT
WHERE LOC='DALLAS';
DDL
CREATE TABLE EMP
(EMPNO NUMBER (4), ENAME VARCHAR2(10), JOB VARCHAR2(20));
DCL
CREATE USER SCOTT
IDENTIFIED BY TIGER;