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進行舉報,并提供相關證據,一經查實,墨天輪將立刻刪除相關內容。




