Oracle DDL,DML,DCL,TCL总结
q! v; e9 I) o# V# |, \ ! \& N) t! u- u5 S
前段时间的浮躁,总觉得这也会,那也会,但是清醒过来发现自己什么都不会,连基本概念都不知道,还是从头来一遍吧,踏踏实实的学习一段时间。) M) J0 S) l3 w: u/ m* H' Y$ P
* `7 }. Q; x6 K/ q) q3 |' A
把oracle学习来可以独挡一面的实施,维护,当然优化是一个很漫长的岁月炼就的经验之谈,需要多积累经验。
6 q% A: T2 ^7 \- i5 m: N $ w5 A, O7 g( G7 n8 F' c% I
下面是一些网上找的资料,自己总结到一起。
* \4 P9 J, g3 j- [& ^% x2 s1 U
/ [5 R" C; t8 u! G' d/ x& z 一般sql语言增删改查和alter,比较常用,oracle里面commit和revoke比较常用,这些对于我来说很迷糊,希望自己踏实下去。
Z# F! m( `% r8 ~* s) n6 _0 W ( x# f2 y" k$ |9 m3 m
DDL
/ }3 G% \- T7 E. Z/ c9 E a! S; ~
6 v4 R3 ~ c: L [ Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:
, T/ l' G5 k* z% C* L; z* O# V
% X1 V* ^5 ]8 F& G) c CREATE - to create objects in the database
D. Z% X& r% E* I; P ' K1 u% c: T% w- \3 Q
ALTER - alters the structure of the database% E# d. }, w' Q* K' }- H5 Z
4 h; A! j2 Y7 W& @; x+ { DROP - delete objects from the database
) P! f7 b+ M! Z. L" f0 S. X . F* [2 x0 W& P$ x& `% q
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
* Z$ o. y$ {4 f- K, m& r / Q9 A0 e& o4 A0 m6 E- R
COMMENT - add comments to the data dictionary9 R# k' A6 m' s- Q" y' i
/ k1 R3 z# k5 F& c# |1 _: h
RENAME - rename an object" y5 i" L! U4 a1 T
0 H* K5 l! X! g DML V/ i r; b0 K1 H& }9 L9 x
4 k Y4 H# j4 v$ x8 U$ U
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
2 E8 z% u6 d8 r, r# I- S, P ' i: U" A. J' d5 V
SELECT - retrieve data from the a database
- G; Z8 q" X) J8 ]2 \- |' u; X" m
! `- P7 B) K, W+ V; O9 M INSERT - insert data into a table, Z& o" c: D1 [4 A8 W
: o$ l' e/ m! a7 J; K( f/ q- F UPDATE - updates existing data within a table, M2 N" A" U9 g4 F L
" r' w* Z; f# A) I0 m# B
DELETE - deletes all records from a table, the space for the records remain
4 n9 `; U7 D$ V: J, b( }
4 d; y( b5 S5 G9 l2 u/ n$ X MERGE - UPSERT operation (insert or update)4 ]/ @. S* e; o2 j1 H C# A/ e
( K3 x; |3 I0 W* A
CALL - call a PL/SQL or Java subprogram
3 W) Z4 U; m( h: J& F9 ]- Y
& w+ ~) j( n: C8 c/ ~ EXPLAIN PLAN - explain access path to data
$ \7 J2 R" I! o. U c
: ]( I# I: O* p$ d% i LOCK TABLE - control concurrency I: O; }, `: M4 L: r( ?
/ p7 u: {5 _+ i9 W$ A DCL
% ]3 P0 L- m0 ?6 `* P " ?$ W8 {/ e i- t5 z8 e
Data Control Language (DCL) statements. Some examples:
4 r$ V9 P: J: C: X2 B" u) b+ B
3 p- G, Z$ f1 g5 M) o3 r, a* w GRANT - gives user's access privileges to database
- W) \7 v, Z9 n( F0 u
/ O+ Y: U# B5 p7 s REVOKE - withdraw access privileges given with the GRANT command
1 P1 q# h/ j ^5 M2 j5 B5 b $ b# }# D& y+ {( F6 y
TCL" C% |2 z. Z4 X! E% k1 B
) V2 G( p _! r( x" B* H
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
* Y) l/ u2 H0 L7 d: @ . D* A, f; ?& ?- K* C0 A
COMMIT - save work done$ s8 Q" k1 [$ W8 }
0 M- x5 p, |. U- ?4 _4 ] SAVEPOINT - identify a point in a transaction to which you can later roll back
8 O/ ^( }: E( P F, q9 g1 ] # s I, I+ c8 I
ROLLBACK - restore database to original since the last COMMIT
+ k; T9 l! q) t
5 _- Z) a- `0 p, p0 | SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
( W) A& }- e4 e1 F% h0 ^; o
1 B9 Z9 i7 M* x* D2 x 上面的比较官方,下面自己的理解和大多数人通俗易懂的形式。 |