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.
删除成功!