GBase 8c
其他
文章

GBase 8c 教程(九)索引基础操作

发表于2023-12-06 17:37:05235次浏览1个评论

1、创建索引——CREATE INDEX语句:
1)查询表:

select * from customer order by id;

返回结果:

 id |  name  |  birthday  |    tel

----+--------+------------+-----------

1 | 刘备   | 2020-04-01 | 123456789  

2 | 关羽   | 2020-04-02 | 132456789  

3 | 张飞   | 2020-04-03 | 142356789  

4 | 曹操   | 2020-04-04 | 154623789  

5 | 孙坚   | 2020-04-05 | 145623789  

6 | 孙策   | 2020-04-06 | 154687923  

7 | 诸葛亮 | 2020-04-07 | 456789123  

8 | 周瑜   |            |  

9 | 黄忠   |            |

10 | 陶谦   |            |

(10 rows)

2)创建索引:

CREATE INDEX customer_id_index ON customer(id);

使用\di命令查看索引情况:

\di

                   List of relations                

 Schema |        Name       | Type  | Owner |  Table

--------+-------------------+-------+-------+----------

 public| customer_id_index | index | gbase | customer

(1 row)

创建成功!

2、删除索引——DROP INDEX语句:
删除命令:

DROP INDEX customer_id_index;

使用\di命令查看索引情况:

Did not find any relations.

删除成功!

评论

登录后才可以发表评论
崔哥发表于 5个月前
千点寒梅晓角中,一番春信画楼东。收灯庭院迟迟月,落索秋千翦翦风。鱼雁杳,水云重,异乡节序恨匆匆。当歌幸有金陵子,翠斝清尊莫放空。