◾SQL language is divided into four types of
primary language statements:
DML, DDL, DCL and TCL. Using these
statements, we can define the structure of a
database by creating and altering database
objects, and we can manipulate data in a table
through updates or deletions. We also can
control which user can read/write data or
manage transactions to create a single unit of
work.
◾1. DML (Data Manipulation Language)
2. DDL (Data Definition Language)
3.DCL (DataControl Language)
4. TCL (TransactionControl Language)
◾5. DRL
◾ DML statements affect records in a table.These
are basic operations we perform on data such as
selecting a few records from a table, inserting
new records, deleting unnecessary records, and
updating/modifying existing records.
◾ DML statements include the following:
◾ SELECT – select records from a table
INSERT – insert new records
UPDATE – update/Modify existing records
DELETE – delete existing records
◾INSERT - insert data into a table
◾UPDATE - updates existing data within a
table
◾DELETE - deletes all records from a table, the
space for the records remain
◾MERGE -UPSERT operation (insert or
update)
◾CALL - call a PL/SQL or Java subprogram
◾EXPLAIN PLAN - explain access path to data
◾LOCKTABLE - control concurrency
◾DDL statements are used to alter/modify a
database or table structure and schema.
These statements handle the design and
storage of database objects.
◾CREATE – create a newTable, database,
schema
ALTER – alter existing table, column
description
DROP – delete existing objects from
database
◾CREATE - to create objects in the database
◾ALTER - alters the structure of the database
◾DROP - delete objects from the database
◾TRUNCATE - remove all records from a table,
including all spaces allocated for the records
are removed
◾COMMENT - add comments to the data
dictionary
◾RENAME - rename an object
◾DCL statements control the level of access
that users have on database objects.
GRANT - gives user's access privileges to
database
GRANT – allows users to read/write on certain
database objects
REVOKE - withdraw access privileges given
with theGRANT command
REVOKE – keeps users from read/write
permission on database objects
◾TCL statements allow you to control and
manage transactions to maintain the
integrity of data withinSQL statements.
◾BEGINTransaction – opens a transaction
COMMITTransaction – commits a
transaction
ROLLBACKTransaction – ROLLBACK a
transaction in case of any error
◾COMMIT - save work done
◾SAVEPOINT - identify a point in a transaction
to which you can later roll back
◾ROLLBACK - restore database to original
since the lastCOMMIT
◾SETTRANSACTION -Change transaction
options like isolation level and what rollback
segment to use
◾TransactionControl Language(TCL)
commands are used to manage transactions
in database.These are used to manage the
changes made by DML statements. It also
allows statements to be grouped together
into logical transactions.
◾Commit command
◾Commit command is used to permanently
save any transaaction into database.
◾Following isCommit command's syntax,
◾commit;
◾Rollback command
◾This command restores the database to last
commited state. It is also use with savepoint
command to jump to a savepoint in a
transaction.
◾Following is Rollback command's syntax,
◾rollback to savepoint-name;
◾Savepoint command
◾savepoint command is used to temporarily
save a transaction so that you can rollback to
that point whenever necessary.
◾Following is savepoint command's syntax,
◾savepoint savepoint-name;
ID NAME
1 dar
2 wahab
4 sadiq
◾INSERT into class values(5,'Rahul'); commit;
UPDATE class set name='abhijit' where id='5';
savepoint A; INSERT into class
values(6,'Chris'); savepoint B; INSERT into
class values(7,'Bravo'); savepoint C; SELECT *
from class;
ID NAME
1 dar
2 wahab
4 sadiq
5 hmftj
6 maha
7 anza
◾rollback to B;SELECT * from class;
ID NAME
1 dar
2 wahab
4 sadiq
5 maha
6 anza
◾rollback toA;SELECT * from class;
ID NAME
1 dar
2 wahab
4 sadiq
5 sarim
◾ DQL: DataQuery LanguageOR
DRL: Data Retrieval Language
◾ DRL means Data Retrieval Language.This will be used
for the retrieval of the data from the database.
In order to see the data present in the database, we
will use DRL statement.We have only one DRL
statement.
◾ SELECT is the only DRL statement inSQL
◾ Select is DRL/DQL i.e. data retrieval Language
◾ DML (Data Manipulation Language). These SQL statements are used to retrieve and
manipulate data.This category encompasses the most fundamental commands including
DELETE, INSERT,SELECT, andUPDATE. DML SQL statements have only minor differences
between SQL variations. DML SQL commands include the following:
◾ DELETE to remove rows.
◾ INSERT to add a row.
◾ SELECT to retrieve row.
◾ UPDATE to change data in specified columns.
◾ DDL (Data Definition Language).These SQL statements define the structure of a database,
including rows, columns, tables, indexes, and database specifics such as file locations. DDL SQL
statements are more part of the DBMS and have large differences between the SQL variations.
DML SQL commands include the following:
◾ CREATE to make a new database, table, index, or stored query.
◾ DROP to destroy an existing database, table, index, or view.
◾ DBCC (DatabaseConsoleCommands) statements check the physical and logical consistency of a
database.
◾ DCL (Data Control Language).These SQL statements control the security and permissions of
the objects or parts of the database(s). DCL SQL statements are also more part of the DBMS and
have large differences between theSQL variations. DML SQL commands include the following:
◾ GRANT to allow specified users to perform specified tasks.
◾ DENY to disallow specified users from performing specified tasks.
◾ REVOKE to cancel previously granted or denied permissions.
◾ »
◾During the execution of DDL command. DDL
command would not copy the actual content
to rollback table space, hence it is fast
compared to DML command.
Sql queries

Sql queries

  • 3.
    ◾SQL language isdivided into four types of primary language statements: DML, DDL, DCL and TCL. Using these statements, we can define the structure of a database by creating and altering database objects, and we can manipulate data in a table through updates or deletions. We also can control which user can read/write data or manage transactions to create a single unit of work.
  • 4.
    ◾1. DML (DataManipulation Language) 2. DDL (Data Definition Language) 3.DCL (DataControl Language) 4. TCL (TransactionControl Language) ◾5. DRL
  • 5.
    ◾ DML statementsaffect records in a table.These are basic operations we perform on data such as selecting a few records from a table, inserting new records, deleting unnecessary records, and updating/modifying existing records. ◾ DML statements include the following: ◾ SELECT – select records from a table INSERT – insert new records UPDATE – update/Modify existing records DELETE – delete existing records
  • 6.
    ◾INSERT - insertdata into a table ◾UPDATE - updates existing data within a table ◾DELETE - deletes all records from a table, the space for the records remain ◾MERGE -UPSERT operation (insert or update) ◾CALL - call a PL/SQL or Java subprogram ◾EXPLAIN PLAN - explain access path to data ◾LOCKTABLE - control concurrency
  • 7.
    ◾DDL statements areused to alter/modify a database or table structure and schema. These statements handle the design and storage of database objects. ◾CREATE – create a newTable, database, schema ALTER – alter existing table, column description DROP – delete existing objects from database
  • 8.
    ◾CREATE - tocreate objects in the database ◾ALTER - alters the structure of the database ◾DROP - delete objects from the database ◾TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed ◾COMMENT - add comments to the data dictionary ◾RENAME - rename an object
  • 9.
    ◾DCL statements controlthe level of access that users have on database objects. GRANT - gives user's access privileges to database GRANT – allows users to read/write on certain database objects REVOKE - withdraw access privileges given with theGRANT command REVOKE – keeps users from read/write permission on database objects
  • 10.
    ◾TCL statements allowyou to control and manage transactions to maintain the integrity of data withinSQL statements. ◾BEGINTransaction – opens a transaction COMMITTransaction – commits a transaction ROLLBACKTransaction – ROLLBACK a transaction in case of any error
  • 11.
    ◾COMMIT - savework done ◾SAVEPOINT - identify a point in a transaction to which you can later roll back ◾ROLLBACK - restore database to original since the lastCOMMIT ◾SETTRANSACTION -Change transaction options like isolation level and what rollback segment to use
  • 12.
    ◾TransactionControl Language(TCL) commands areused to manage transactions in database.These are used to manage the changes made by DML statements. It also allows statements to be grouped together into logical transactions.
  • 13.
    ◾Commit command ◾Commit commandis used to permanently save any transaaction into database. ◾Following isCommit command's syntax, ◾commit;
  • 14.
    ◾Rollback command ◾This commandrestores the database to last commited state. It is also use with savepoint command to jump to a savepoint in a transaction. ◾Following is Rollback command's syntax, ◾rollback to savepoint-name;
  • 15.
    ◾Savepoint command ◾savepoint commandis used to temporarily save a transaction so that you can rollback to that point whenever necessary. ◾Following is savepoint command's syntax, ◾savepoint savepoint-name;
  • 16.
    ID NAME 1 dar 2wahab 4 sadiq
  • 17.
    ◾INSERT into classvalues(5,'Rahul'); commit; UPDATE class set name='abhijit' where id='5'; savepoint A; INSERT into class values(6,'Chris'); savepoint B; INSERT into class values(7,'Bravo'); savepoint C; SELECT * from class;
  • 18.
    ID NAME 1 dar 2wahab 4 sadiq 5 hmftj 6 maha 7 anza
  • 19.
  • 20.
    ID NAME 1 dar 2wahab 4 sadiq 5 maha 6 anza
  • 21.
  • 22.
    ID NAME 1 dar 2wahab 4 sadiq 5 sarim
  • 23.
    ◾ DQL: DataQueryLanguageOR DRL: Data Retrieval Language ◾ DRL means Data Retrieval Language.This will be used for the retrieval of the data from the database. In order to see the data present in the database, we will use DRL statement.We have only one DRL statement. ◾ SELECT is the only DRL statement inSQL ◾ Select is DRL/DQL i.e. data retrieval Language
  • 24.
    ◾ DML (DataManipulation Language). These SQL statements are used to retrieve and manipulate data.This category encompasses the most fundamental commands including DELETE, INSERT,SELECT, andUPDATE. DML SQL statements have only minor differences between SQL variations. DML SQL commands include the following: ◾ DELETE to remove rows. ◾ INSERT to add a row. ◾ SELECT to retrieve row. ◾ UPDATE to change data in specified columns. ◾ DDL (Data Definition Language).These SQL statements define the structure of a database, including rows, columns, tables, indexes, and database specifics such as file locations. DDL SQL statements are more part of the DBMS and have large differences between the SQL variations. DML SQL commands include the following: ◾ CREATE to make a new database, table, index, or stored query. ◾ DROP to destroy an existing database, table, index, or view. ◾ DBCC (DatabaseConsoleCommands) statements check the physical and logical consistency of a database. ◾ DCL (Data Control Language).These SQL statements control the security and permissions of the objects or parts of the database(s). DCL SQL statements are also more part of the DBMS and have large differences between theSQL variations. DML SQL commands include the following: ◾ GRANT to allow specified users to perform specified tasks. ◾ DENY to disallow specified users from performing specified tasks. ◾ REVOKE to cancel previously granted or denied permissions. ◾ »
  • 25.
    ◾During the executionof DDL command. DDL command would not copy the actual content to rollback table space, hence it is fast compared to DML command.