1. 创建表空间,表空间tspc1使用相对路径指定所在目录,表空间tspc2指定owner为Lucy
CREATE TABLESPACE tspc1 RELATIVE LOCATION 'tablespace/tspc1';
CREATE ROLE Lucy IDENTIFIED BY 'abce@123';
CREATE TABLESPACE tspc2 OWNER Lucy RELATIVE LOCATION 'tablespace/tspc2';omm=# \db
List of tablespaces
Name | Owner | Location
------------+-------+------------------
pg_default | omm |
pg_global | omm |
tspc1 | omm | tablespace/tspc1
tspc2 | lucy | tablespace/tspc2
(4 rows)
2.在表空间tspc1中建表,并使用视图pg_tables查看信息
create table customer
( c_customer_sk integer,
c_customer_id char(5),
c_first_name char(6),
c_last_name char(8)
) tablespace tspc1;;
select * from pg_tables where tablename = 'customer';omm=# select * from pg_tables where tablename = 'customer';
public | customer | omm | tspc1 | f | f | f | omm | 2021-12-07 14:25:11.866475+08 | 2021-12-07 14:25:11.8664
75+08
(1 row)
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | tablecreator | created | last_ddl_time
------------+-----------+------------+------------+------------+----------+-------------+--------------+-------------------------------+-------------------------
------
omm=# 3.重命名tspc1,修改tspc2的用户为Lily,使用\db查看表空间信息
ALTER TABLESPACE tspc1 RENAME TO tspc101;
CREATE ROLE Lily IDENTIFIED BY 'abcd@789';
ALTER TABLESPACE tspc2 OWNER TO Lily;
\dbomm=# \db
List of tablespaces
Name | Owner | Location
------------+-------+------------------
pg_default | omm |
pg_global | omm |
tspc101 | omm | tablespace/tspc1
tspc2 | lily | tablespace/tspc2
(4 rows)
4.删除表空间
drop table customer;
DROP TABLESPACE IF EXISTS tspc2;
DROP TABLESPACE IF EXISTS tspc101;「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




