每日一练:openGauss数据库在线实训课程 ## 第六天作业

0.模式

openGauss的模式是对数据库做一个逻辑分割。所有的数据库对象都建立在模式下面。openGauss的模式和用户是弱绑定的,所谓的弱绑定是指虽然创建用户的同时会自动创建一个同名模式,但用户也可以单独创建模式,并且为用户指定其他的模式。

1.创建一个名为tpcds的模式

\dn+ 
create schema tpcds;
\dn

2.创建一个用户tim, 并将tpcds的owner修改为tim,且修改owner前后分别使用\dn+查看模式信息

\dn+ tpcds
create user tim password 'tpcds@123';
alter schema tpcds owner to tim; 
\dn+ tpcds

3.重命名tpcds为tpcds1

\du+ 
alter schema tpcds rename to tpcds1;
\du+ 

4.在模式tpcds1中建表customer、插入记录和查询记录

create table tpcds1.customer(id int, name varchar2(20));
insert into tpcds1.customer values(1, 'bpx');
select * from tpcds1.customer;

5.删除模式tpcds1

\d+ tpcds1.customer;
drop schema tpcds1; --报错
drop schema tpcds1 cascade;
\d+ tpcds1.customer;

猜你喜欢

转载自blog.csdn.net/hezuijiudexiaobai/article/details/121799548