oracle資料庫學習

2021-06-18 07:09:14 字數 770 閱讀 6956

最近在做使用者資料篩選的時候發現使用者資料載入和查詢比較慢,所以,參考網上資料進行了寫小優化,在資料庫中執行快了那麼一些,在這裡記錄下相關命令。

做法:建立字段索引,使用instr函式。

1:使用instr代替like %...%。(%開頭會導致索引失效),instr的基本用法:

select count(*) from 表名 where instr(t.column,』xx』)> 0

2:查詢某張別結構對應的索引:

檢視某張表的總體索引資訊:

sql> select * from user_indexes where table_name ='表名' ;

檢視某張表的索引字段:

sql> select * from user_ind_columns where index_name=『索引名』;//可以從上面的命令結果檢視到

3:檢視使用者許可權:

檢視自己的許可權和角色 select * from user_tab_privs; select * from user_role_privs;

sys使用者檢視任一使用者的許可權和角色 select * from dba_tab_privs; select * from dba_role_privs;

4:建立索引:

create index 索引名稱 on 表名('username' asc,'realname' asc);

5:刪除索引:

drop index 索引名

6:重建索引:

alter index 索引名 rebuild

Oracle資料庫學習

本章學習要點 1 子查詢 將乙個查詢包含到另乙個查詢中 1 如 emp表中,查詢與 scott 在同乙個部門的雇員資訊 原來我們是先查詢scott所在的部門即 select deptno from emp where ename scott 然後通過返回的部門號在查詢員工資訊 select from...

Oracle資料庫學習

本章學習要點 概念 序列是用於生成唯 一 連續序號的物件序列可以是公升序的,也可以是降序的使用create sequence語句建立序列 語法 create sequence 序列化的名稱 start with 10 開始10 increment by 10 每次步長10 maxvalue 2000...

Oracle資料庫學習

ddl data definition languag 資料定義語言 用來定義和修改表物件的語言.操作的物件是 使用者,資料庫 oracle中只有乙個全域性資料庫 表,表空間 oracle中才有的 試圖之類的,不會對具體資料進行操作 dml data manipulation language 資料...