暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss每日一练第6天|openGauss中用户一次只能连接到一个数据库,没法访问其他数据库的对象

原创 xxxxxxx 2022-11-29
803

学习目标

学习openGauss体系结构,通过实验,了解用户一次只能连接到一个数据库,没法访问其他数据库的对象。(注:本实验没有使用dblink插件)

课后作业

1.创建用户user1,分别在数据库musicdb1、数据库musicdb2创建表t11,t21

--执行下面的SQL语句,创建用户user1:
 CREATE USER user1 IDENTIFIED BY 'kunpeng@1234';
 
--授予user1数据库系统的SYSADMIN权限:
ALTER USER user1 SYSADMIN;

--用户user1登录到数据库musicdb1,创建表t11,并插入、查看数据
 \c musicdb1 user1

 create table t11(col1 char(20));
 insert into t11 values('Hello openGauss! 11');
 select * from t11;

--用户user1登录到数据库musicdb2,创建表t21,并插入、查看数据
  \c musicdb2 user1

 create table t21(col1 char(20));
 insert into t21 values('Hello openGauss! 22');
 select * from t21;

image.png
image.png
image.png
2.user1用户连接到数据库musicdb1,并访问数据库musicdb1下的表t11

–使用user1用户连接到数据库musicdb1,访问数据库musicdb1下的表t11

\c musicdb1 user1
select * from musicdb1.public.t11;

image.png
3.在这个连接中(使用数据库用户user1连接到数据库musicdb1)访问数据库musicdb2下的t21表(会报错)

select * from musicdb2.public.t21;

image.png
4.使用数据库用户user1连接到数据库musicdb2,访问数据库musicdb2下的t21表。

--可以正常访问,数据库中的表是存在的。但不能跨库访问。
\c musicdb2 user1
 select * from musicdb2.public.t21;

image.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论