DDL Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:$ m* M5 o, C4 `3 x7 \: |5 O3 B4 d
CREATE - to create objects in the database
3 O' m$ n( V) @8 N# h8 j) _% C ALTER - alters the structure of the database2 i+ E1 ^, b2 }) b6 ?1 H' u
DROP - delete objects from the database3 M3 a5 b u, v8 {6 m6 {
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
2 i4 ~2 |3 I& f5 O8 @5 _7 g COMMENT - add comments to the data dictionary/ Y5 ]9 K/ Q- X. N' S- g4 x
RENAME - rename an object
- ?8 f% u. _2 s DML; H& H- q$ g: h2 @8 S
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:/ S! D4 ]2 F" e, T/ l9 W
SELECT - retrieve data from the a database* ?! h8 ^5 \2 x2 _* m( D. ]
INSERT - insert data into a table
4 t9 l2 E/ W4 ?9 t1 Z UPDATE - updates existing data within a table
# {9 T3 U, v- D/ J; I. ^2 j$ G0 {8 F DELETE - deletes all records from a table, the space for the records remain" x1 y" a5 N) |/ D. Q4 z
MERGE - UPSERT operation (insert or update)
5 r; |' G1 N+ p5 C1 G% h' X CALL - call a PL/SQL or Java subprogram
; C* L, ^8 \9 k# o7 U0 ~9 Y" H EXPLAIN PLAN - explain access path to data' j) r4 K! B# ~7 M9 q
LOCK TABLE - control concurrency5 r T- W; J* f4 d0 l, X5 {
DCL1 y! S6 o, @' K' m8 V
Data Control Language (DCL) statements. Some examples:
$ R8 B7 S. ^2 _8 y, p0 |; a GRANT - gives user's access privileges to database+ M; r/ D& H4 t* G6 \7 s
REVOKE - withdraw access privileges given with the GRANT command! }8 ^2 I# f- K; W. u
TCL6 n9 l' g+ H# F' k
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.( B4 F% Z8 A% z" @- D
COMMIT - save work done2 B2 B, K R+ b, }
SAVEPOINT - identify a point in a transaction to which you can later roll back
" u5 b" [" i7 W# T& y' O ROLLBACK - restore database to original since the last COMMIT
* r/ z# p! t9 r$ e; l* D; a SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use |