1. 程式人生 > >Oracle知識點彙總(一)更清晰,更透徹,持續更新中!

Oracle知識點彙總(一)更清晰,更透徹,持續更新中!

一.sql語言類別。

1.      DDL(資料定義語言):create(建立),alter(修改)和drop(刪除)命令。

2.      DML(資料操縱語言):insert(插入),select(查詢),delete(刪除),update(更新)命令。

3.      TCL(事務控制語言):commit(提交),savepoint(儲存點),rollback(回滾)命令。

4.      DCL(資料控制語言):grant(授予),revoke(回收)。

二.oracle的大資料儲存型別。

  Blob(用來儲存多達4GB的二進位制資料),CLOB(用來儲存多達4GB的字元資料),BFILE(用來儲存多達4GB的二進位制資料。

三.對錶的一些修改操作

   1.例: 對student表的student_id新增主鍵約束

     Alter table student

      Add constraint student_pk primary key(student_id);

   2.為student新增一個欄位 age

     Alter table student

      Add age number;

   3.修改name列的大小,將varchar(10),變為varchar(20).

     Alter table student

      Modify name varchar2(20);

4.刪除表

Drop table student;

5. 表的重新命名

Rename student tonewstudent;

四.事務控制語言的四個屬性(ACID)。

原子性,一致性,隔離性,永續性。

當一個時間需要全部操作完成時,可以考慮使用事務,比如銀行的轉賬操作。

五.在oracle中包含rowid和rownum兩個偽列。

1.我們可以使用rowid來刪除表中的重複資料

  delete表名 where rowid not in(selectmax(rowid) from 表名 group by 所有的欄位名);

  例:

   delete emp where rowid not in(select max(rowid) from emp group byempid,empname);

2.我們可以使用rownum來實現分頁的效果。

  例:使用ruwnum查詢出分頁資訊來,假設一頁要查詢出5個數據。

 select * from (select e.*,rownum rn from 表名 e) where rn>5(n-1) and rn<5n+1;

  例: 

 select * from (select e.*,rownum rn from emp e)where rn>0 andrn<6;