openGauss每日一练第7天课后作业
1.创建表空间,表空间tspc1使用相对路径指定所在目录,表空间tspc2指定owner为Lucy
create tablespace tspc1 relative location 'tablespace/tspc1';
create tablespace tspc2 location '/gauss/data/dn/pg_location/tablespace/tspc2';
--使用绝对路径创建表空间时,不能指定在数据目录
create tablespace tspc2 location '/data/tspc2';
create user lucy password 'gauss_4U';
alter tablespace tspc2 owner to lucy;
\db
2.在表空间tspc1中建表,并使用视图pg_tables查看信息
create table t1207 (id int, name char(20)) tablespace tspc1;
select * from pg_tables where tablename='t1207';
3.重命名tspc1,修改tspc2的用户为Lily,使用\db查看表空间信息
alter tablespace tspc1 rename to tspc10;
create user lily password 'gauss_4U';
alter tablespace tspc2 owner to lily;
\db
4.删除表空间
drop tablespace tspc10;
--只能删除空的表空间
--查找该表空间中有哪些表和索引,先进行删除
select tablename from pg_tables where tablespace='tspc10';
--select indexname from pg_indexes where tablespace='tspc10';
drop table t1207;
drop tablespace tspc10;
drop tablespace tspc2;