資料庫索引 常用指令

2021-09-19 05:12:05 字數 1407 閱讀 8307

create [unique] | [bitmap] index index_name  --unique表示唯一索引

on table_name([column1 [asc|desc],column2 --bitmap,建立位圖索引

[asc|desc],…] | [express])

[tablespace tablespace_name]

[pctfree n1] --指定索引在資料塊中空閒空間

[storage (initial n2)]

[nologging] --表示建立和重建索引時允許對錶做dml操作,預設情況下不應該使用

[noline]

[nosort]; --表示建立索引時不進行排序,預設不適用,如果資料已經是按照該索引順序排列的可以使用

drop index index_name;
alter index index_name_old rename to index_name_new;
alter index index_name rebuild;
select a.owner,

a.index_name,

a.index_type,

a.table_name,

b.column_name,

b.column_length

from all_indexes a, user_ind_columns b

where a.index_name = b.index_name

and a.table_name = '表名';

--執行索引分析

analyze index index_name validate structure;

--執行碎片分析

select name,height,pct_used,del_lf_rows/lf_rows from index_stats where name='index_name';

--出現以下兩種情況,需要重建索引或者合併索引

--1、pct_used < 50%

--2、del_lf_rows/lf_row > 0.2

--如果經過索引分析,需要重建索引,則執行:

alter index index_name rebuild;

--再次執行索引分析,讓索引利用率及時更新

analyze index index_name validate structure;

mongodb資料庫常用指令

詳細安裝看我文章 開啟在bin目錄下mongo.exe來運算元據庫 常用命令 show dbs 檢視所有庫 use blog 使用指定的庫 show collections 檢視所有的文件 db.表名.find 查詢指定文件的資料 db.表名.insert 插入資料 3.將mongodb服務加入到w...

linux資料庫常用指令

linux資料庫環境搭建好之後,我們就可以建立資料庫了,如果不是 首先我們來建立乙個資料庫 使用指令sqlite3 mysql 指令1 建立 create table 表名 資料型別 約束條件 create table mysql id integer primary key autoincreme...

資料庫 資料庫索引

索引是儲存引擎用於快速找到記錄的一種資料結構。索引以檔案的形式儲存在磁碟中。索引可以包含乙個或多個列的值。儲存引擎查詢資料的時候,先在索引中找對應值,然後根據匹配的索引記錄找到對應的資料行。1.b tree索引 2.雜湊索引 myisam和innodb儲存引擎 只支援btree索引,也就是說預設使用...