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

openGauss每日一练第5天 | 学习心得体会

原创 怕晒的太阳 2022-11-28
197

学习目标

学习openGauss体系结构,使用一个用户访问多个数据库。

学习内容

上一节课,了解多个用户可以访问一个数据库,本节课学习了一个用户访问多个数据库。

1.创建三个数据库。

2.创建一个用户,授权sysadmin权限。

3.用创建的用户登录分别登录三个数据库。建表、插入数据、查询。


课后作业

1.创建数据库musicdb10,创建用户user10,赋予sysadmin权限

create database musicdb10;

--执行下面的SQL语句,创建用户user10:

CREATE USER user10 IDENTIFIED BY 'test@1234'; 

--授予user1数据库系统的SYSADMIN权限: 

ALTER USER user10 SYSADMIN;


create user默认有登录权限,但是不能操作数据库的权限


2.用户user10访问数据库postgres,创建一个表并插入数据

\c postgres user10create table products1(product_id integer,product_name char(20),category char(30));
insert into products1 values(1502,'olympus camera','electrncs'),(1601,'lamaze','toys'),(1700,'wait interface','Books'),(1666,'harry potter','toys');
select * from products1;


3.用户user10访问数据库omm,创建一个表并插入数据

\c omm user10
create table products1(product_id integer,product_name char(20),category char(30));
insert into products1 values(1502,'olympus camera','electrncs'),(1601,'lamaze','toys'),(1700,'wait interface','Books'),(1666,'harry potter','toys');
select * from products1;


4.用户user10访问数据库musicdb10,创建一个表并插入数据

\c musicdb10 user10
create table products1(product_id integer,product_name char(20),category char(30));
insert into products1 values(1502,'olympus camera','electrncs'),(1601,'lamaze','toys'),(1700,'wait interface','Books'),(1666,'harry potter','toys');
select * from products1;
omm=> \c musicdb10 user10
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=> create table products1(product_id integer,product_name char(20),category char(30));
CREATE TABLE
musicdb10=> insert into products1 values(1502,'olympus camera','electrncs'),(1601,'lamaze','toys'),(1700,'wait interface','Books'),(1666,'harry potter','toys');
INSERT 0 4
musicdb10=> select * from products1;

product_id | product_name | category 
------------+----------------------+--------------------------------
1502 | olympus camera | electrncs
1601 | lamaze | toys 
1700 | wait interface | Books 
1666 | harry potter | toys 
(4 rows)
最后修改时间:2022-11-28 10:31:51
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论