暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss 创建索引

suger 2023-01-10
643

创建唯一索引
create unique index t1_fn_idx on t1(relfilenode); 

创建复合索引
create index t1_owner_tbs_idx on t1(relowner,reltablespace);

创建部分索引
create index t1_lttbs_idx on t1(reltablespace) where reltablespace<20; 

创建函数索引
create index t1_upname_idx on t1(upper(relname)); 

创建分区表的本地索引
create index pt1_id_idx on pt1(id) local; 

创建分区表的全局索引
create index pt1_score_idx on pt1(score) global tablespace tbs1; 

修改索引
alter index t1_fn_idx rename to t1_fn_idx2;
alter index t1_fn_idx2 set tablespace tbs2;
alter index t1_lttbs_idx unusable;
alter index t1_lttbs_idx rebuild;

修改分区索引
alter index pt1_id_idx rebuild partition p1_id_idx;
alter index pt1_id_idx modify partition p1_id_idx unusable;
alter index pt1_id_idx rename partition p1_id_idx to p1_id_idx2;
alter index pt1_id_idx move partition p1_id_idx2 tablespace tbs1;

删除索引
drop index t1_lttbs_idx;

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论