使用一个用户访问多个数据库。
1 opengauss删除用户 无法级联删除?
openGauss=# drop user user1 cascade;
ERROR: role "user1" cannot be dropped because some objects depend on it
DETAIL: 2 objects in database musicdb2
openGauss=#
后面从 postgres 数据库切到 musicdb2 后, 删除可以成功
例子见下面的评论
2 create user user10
CREATE DATABASE musicdb10 WITH TABLESPACE = music_tbs;
CREATE USER user10 IDENTIFIED BY 'kunpeng@1234';
ALTER USER user10 SYSADMIN;
\c postgres user10
create table t_postgresdb_t1(col1 char(20));
insert into t_postgresdb_t1 values('user10 in pg');
\c musicdb10 user10
create table t_db10_t1(col1 char(20));
insert into t_db10_t1 values('user10 indb10');
3 user10 select
注意 user10 用户下的表,所在的scheam 名,一个是public 一个是 scheam user10
[omm@node1 ~]$ gsql -d postgres -p 26000 -r -U user10
Password for user user10:
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=> \dt
List of relations
Schema | Name | Type | Owner | Storage
--------+-----------------+-------+--------+----------------------------------
user10 | t_postgresdb_t1 | table | user10 | {orientation=row,compression=no}
(1 row)
openGauss=> select *from t_postgresdb_t1;
col1
----------------------
user10 in pg
(1 row)
openGauss=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+----------+------------+------------+-------------------
musicdb | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
musicdb1 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
musicdb10 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
musicdb2 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
musicdb3 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
postgres | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
template0 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/omm +
| | | | | omm=CTc/omm
zyfdb | omm | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
(9 rows)
openGauss=> \c musicdb10
Password for user user10:
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "musicdb10" as user "user10".
musicdb10=> \dt
List of relations
Schema | Name | Type | Owner | Storage
--------+-----------+-------+--------+----------------------------------
public | t_db10_t1 | table | user10 | {orientation=row,compression=no}
(1 row)
musicdb10=> select * from t_db10_t1;
col1
----------------------
user10 indb10
(1 row)
musicdb10=>
最后修改时间:2022-11-29 10:36:44
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




