0. 进入环境
su - omm
gsql -r
1.创建一个名为tpcds的模式
CREATE SCHEMA tpcds;
\dn+ tpcds;
– 回显
List of schemas
Name | Owner | Access privileges | Description
-------+-------+-------------------+-------------
tpcds | omm | |
(1 row)
2.创建一个用户tim, 并将tpcds的owner修改为tim,且修改owner前后分别使用\dn+查看模式信息
CREATE USER tim PASSWORD 'abcd@123';
\du
– 回显
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
List of roles
Role name | Attributes | Member of
-----------+-------------------------------+-----------
gaussdb | Sysadmin | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operat
oradmin, Policyadmin, UseFT | {}
tim | | {}
ALTER SCHEMA tpcds OWNER TO tim;
\dn+ tpcds;
– 回显
List of schemas
Name | Owner | Access privileges | Description
-------+-------+-------------------+-------------
tpcds | tim | |
(1 row)
3.重命名tpcds为tpcds1
ALTER SCHEMA tpcds RENAME TO tpcds1;
– 回显
ALTER SCHEMA
4.在模式tpcds1中建表customer、插入记录和查询记录
create table tpcds1.customer(id int, name char(30));
insert into tpcds1.customer values(1 ,'xxxx');
select * from tpcds1.customer;
id | name
----+--------------------------------
1 | xxxx
(1 row)
\d+ tpcds1.customer;
Table "tpcds1.customer"
Column | Type | Modifiers | Storage | Stats target | Description
--------+---------------+-----------+----------+--------------+-------------
id | integer | | plain | |
name | character(30) | | extended | |
Has OIDs: no
Options: orientation=row, compression=no
5.删除模式tpcds1
DROP SCHEMA tpcds1 CASCADE;
DROP USER tim;
– 回显
DROP SCHEMA
DROP ROLE
最后验证观察下
\dn+ tpcds1
– 回显
List of schemas
Name | Owner | Access privileges | Description
------+-------+-------------------+-------------
(0 rows)
\du+ tim
– 回显
List of roles
Role name | Attributes | Member of | Description
-----------+------------+-----------+-------------
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。