1.表空间管理
--查询表空间
Select spcname from pg_tablespace;
\db
--查看表空间的使用情况
Select pg_tablespace_size('pg_default');
--删除表空间
2.索引管理
(1)聚集索引
---创建表,在第一列上建聚集索引:
create table t_1(c1 int, c2 char(10), c3 date);
create index ind_1 on t_1(c1);
---查看t_1表上所有索引:
\d t_1
---删除索引
drop index ind_1;
(2)hash索引
--HASH索引
---创建表及索引
create table t_2(c1 int, c2 char(10), c3 date);
create index hash_index on t_2 using hash(c2);
---列出 t_2 表的所有索引
\d t_2
(3)唯一索引
---创建表
CREATE TABLE ship_mode_t1
(
SM_SHIP_MODE_SK INTEGER NOT NULL,
SM_SHIP_MODE_ID CHAR(16) NOT NULL,
SM_TYPE CHAR(30),
SM_CODE CHAR(10),
SM_CARRIER CHAR(20),
SM_CONTRACT CHAR(20)) ;
---在表ship_mode_t1上的SM_SHIP_MODE_SK字段上创建索引。
CREATE UNIQUE INDEX ds_ship_mode_t1_index1 ON ship_mode_t1(SM_SHIP_MODE_SK);
---查看表的所有索引:
\d ship_mode_t1
---删除索引
drop index ds_ship_mode_t1_index1;
3.常用DML语句
---创建表
drop table if exists test01;
create table test01(id integer, val char(8));
---insert
insert into test01 values(1,'山东');
insert into test01 values(2,'烟台');
---Delete
Delete test01 where id=1;
---Update
Update test01 set id=10 where id=2;
---Select
Select * from test01;
最后修改时间:2022-08-31 18:29:56
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。