有關索引的語句

2021-08-25 01:56:40 字數 751 閱讀 6185

建立索引:

create index indexname on tablename(columnname) tablespace tablespacename;

重建索引:

alert index indexname rebuild (nologging);

若rebuild後跟online可減少鎖表的時間。

刪除索引:

drop index indexname;

建立唯一索引:

create unique index indexname on tabel (colu);

組合索引;\

create index indexname on table(col1,col2);

基於函式的索引:

create index indexname on table(lower(col));

涉及到索引的資料字典檢視:

user_indexes ,dba_indexes,all_indexes:使用者建立索引的資訊

user_ind_partitions:分割槽索引的資訊

user_ind_columns:與索引有關的表列的資訊

對錶和索引進行分析:

analyze table tablename compute statistics for all indexes;

注意:臨時表不能重建索引,在user_indexes表中含有一欄位temporary=『y』or 『n』;

索引在該錶上有鎖資訊時不能重建。

mysql有關索引 有關MySQL索引的一點補充

like xx select from tb1 where name like cn 未使用索引 select from tb1 where name like cn 使用索引 使用函式 未使用索引 select from tb1 where reverse name hwan 使用索引 selec...

MySql有關索引的優化

一 寫sql需要注意的?1.在where及order by之後建立索引。2.避免使用 和 會導致索引無效。3.有關null值問題 例如 select from user where is null,避免使用 應給 設定乙個預設的值0。4.避免使用or查詢,否則會放棄索引。可以使用union all替...

有關switch語句的總結

switch語句其一般形式如下 switch 表示式 switch語句的功能是 根據switch後面表示式的值找到匹配的入口處,就從此入口處開始執行下去,不再進行判斷。比如程式 switch class 若class的值為 b 則輸出的結果是 good ok no error 若class的值為 z...