There are six types of Oracle SQL Statements.
- Data Definition Language (DDL) Statements
- Data Manipulation Language (DML) Statements
- Transaction Control Statements
- Session Control Statements
- System Control Statements
- Embedded SQL Statements
What are Data Definition Language (DDL) Statements ?
- DDL statements can neither be rolled back nor need to be committed.
- DDL statements are auto-commit.
- DDL statements create, alter, drop users, objects, database structure and database also.
- for example
- create
- alter
- drop
- Assign or Remove privileges and roles
- for example
- grant
- revoke
- Turn auditing on or off
- for example
- audit
- noaudit
- Empty the table (delete all data from the data and reset high water mark)
- for example
- truncate
- Comments for an objects
- for example
- comment
What are Data Manipulation Language (DML) Statements ?
- DML statements can either be rolled back or commited.
- If a DDL is issued immediately after DML all previous DML transactions are committed.
- i.e. DDL issues a commit or is an auto-commit.
- DML statements are used to query or manipulate data
- Statement to query data
- select
- Statement to add data
- insert
- Statement to manipulate (change) data
- update
- Statement to insert data or update data based on condition
- merge
- Statement to delete data (not truncate)
- delete
- Statement to see execution plan for any of the above DML Statements
- explain plan
- Statement to lock of limit access to an object (table or view)
- lock table
What are Transaction Control Statements ?
- These statements help manage the changes made by DML statements
- Make transaction changes permanent
- commit
- Remove (undo) transaction changes
- rollback
- Set a save point to undo changes
- savepoint
- Set properties for a transaction
- set transaction
What are Session Control Statements ?
- Session Control Statements allow you to manage and control the properties of a user session.
- Alter current session properties
- alter session
- for example
- data format using
- alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
- enable or disable SQL tracing
- alter session set SQL_TRACE = TRUE;
- alter session set SQL_TRACE = FALSE:
- enable or disable roles for a current session
- set role
- for example
- set role all except data_modify;
What are System Control Statements ?
- System Control Statement are used to change the database instance properties
- alter system
- for example
- Enables you to set system level parameters
- alter system set sec_case_sensitive_logon=true;
- Enables you to terminate a session
- alter system kill session "
, ;
What are Embedded SQL Statements ?
- Embedded SQL Statements use DDL, DML and Transaction Control Statements within a procedural language (viz : procedure, package, function....)
- They enable you to
- Define, allocate and release cursors
- declare
- open
- close
- Retrieve data from database
- fetch
- Specify a database and connect to it
- declare database
- connect
- Assign variable names
- declare statement
- Initialize descriptors
- describe
- Specify how error and warning conditions are handled
- whenever
- Parse and run SQL statements
- prepare
- execute
- execute immediate
Reference or Source : Various : Oracle documentation, Internet, Personal experience.
No comments:
Post a Comment