> 准备工作
🍩连接openGauss
su - omm
gsql -r
复制
> 作业打卡
1.创建表products, 分别为表创建一个unique索引1,指定b-tree索引2和表达式索引3
CREATE TABLE products
(product_id integer,product_name char(30),category char(20));
comment on column products.product_id is '产品编号';
comment on column products.product_name is '产品名';
comment on column products.category is '种类';
CREATE UNIQUE INDEX products_index1 ON products(product_id);
CREATE INDEX products_index2 ON products USING btree(product_id);
CREATE INDEX products_index3 ON products(SUBSTR(product_name,1 ,4));
复制
2.设置索引1不可用,修改索引2的表空间,重命名索引3
ALTER INDEX products_index1 UNUSABLE;
CREATE TABLESPACE example0 RELATIVE LOCATION 'tablespace1/tablespace_0';
ALTER INDEX products_index2 set tablespace example0;
\d+ products_index2;
ALTER INDEX products_index3 RENAME TO products_index33;
复制

3.重建索引2和products的所有索引
ALTER INDEX products_index1 REBUILD;
REINDEX INDEX products_index2;
reindex table products;
\di
复制
4.使用\d+和系统视图pg_indexes查看索引信息
\d+
select * from pg_indexes where tablename = 'products';
复制
5.删除索引、表和表空间
5.删除索引、表和表空间
\db
\di
\d public.products;
DROP INDEX products_index1;
DROP INDEX products_index2;
DROP INDEX products_index33;
DROP TABLE products;
DROP TABLESPACE example0;
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
内蒙古公司成功完成新一代BOSS云原生系统割接上线
openGauss
177次阅读
2025-03-24 09:40:40
第4期 openGauss 中级认证OGCP直播班招生中!3月30日开课
墨天轮小教习
143次阅读
2025-03-17 15:48:40
从数据库源码比较 PostgreSql和OpenGauss的启动过程
maozicb
53次阅读
2025-03-24 15:55:04
openGauss HASH JOIN原理
lbsswhu
47次阅读
2025-03-18 10:45:01
民生银行测试用例参数
Cabbage
46次阅读
2025-03-05 09:35:20
对话openGauss开发者之天津大学游奕桁
openGauss
36次阅读
2025-02-28 14:54:31
openGauss 学习之路:集群部署实战探索
openGauss
32次阅读
2025-03-21 10:34:13
openGauss问题记录:开启备机归档且备机stop情况下,执行gs_probackup失败
zym
29次阅读
2025-03-18 19:06:13
openGauss 首届委员会线下联合例会:融合用户视角,共话技术规划
openGauss
28次阅读
2025-03-05 11:09:25
【GaussDB每日一贴】aclexplode函数的使用
猪踢库
26次阅读
2025-03-23 20:35:26