第5天 | openGauss中一个用户可以访问多个数据库

接着昨天继续学习openGauss,今天是第五天了。今天学习内容是使用一个用户访问多个数据库。

老规矩,先登陆墨天轮为我准备的实训实验室

复制代码
root@modb:~# su - omm
omm@modb:~$ gsql -r
创建表空间music_tbs、数据库musicdb10 、用户user10 并赋予 sysadmin权限
复制代码
omm=# CREATE TABLESPACE music_tbs RELATIVE LOCATION 'tablespace/test_ts1';
CREATE TABLESPACE
omm=# CREATE DATABASE musicdb10 WITH TABLESPACE = music_tbs;
CREATE DATABASE
omm=#  CREATE USER user10 IDENTIFIED BY 'user10@1234';
NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# ALTER USER user10 SYSADMIN;
ALTER ROLE
以用户user10 -的身份在数据库postgres 中创建表products1,并插入一条数据
复制代码
omm=# \c postgres  user10
Password for user user10: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "postgres" as user "user10".
openGauss=> create table products1 (product_id int,product_name char(20),category char(30) );
CREATE TABLE
openGauss=> insert into products1  values(1502,'olympus camera','electrncs');
INSERT 0 1
openGauss=> select * from products1 ;
 product_id |     product_name     |            category            
------------+----------------------+--------------------------------
       1502 | olympus camera       | electrncs                     
(1 row)                     
以用户user10 -的身份在数据库omm 中创建表products1,并插入一条数据
复制代码
openGauss=> \c omm user10
Password for user user10: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "omm" as user "user10".
omm=> create table products1 (product_id int,product_name char(20),category char(30) );
CREATE TABLE
omm=> insert into products1  values(1502,'olympus camera','electrncs');
INSERT 0 1
omm=> select * from products1 ;
 product_id |     product_name     |            category            
------------+----------------------+--------------------------------
       1502 | olympus camera       | electrncs                     
(1 row)                     
以用户user10 -的身份在数据库musicdb10 中创建表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=> 
musicdb10=> create table products1 (product_id int,product_name char(20),category char(30) );
CREATE TABLE
musicdb10=> insert into products1  values(1502,'olympus camera','electrncs');
INSERT 0 1
musicdb10=> select * from products1 ;
 product_id |     product_name     |            category            
------------+----------------------+--------------------------------
       1502 | olympus camera       | electrncs                     
(1 row)                     
总结

今天学习内容非常简单,还是以创建用户,创建数据库,授予权限,建表,插入数据为主。多多练习。

相关推荐
毅炼35 分钟前
多 Agent 不会自动提速:先看任务图和改动怎么合
数据库·软件工程
GeW41 分钟前
入行 Linux 与数据库运维:一条路径、三项习惯、一个考证观
linux·数据库
拖延症晚期的Liu3 小时前
数据表的操作
大数据·数据库·sql
FungLeo6 小时前
FengCMS · PHP+MySQL 升级实录 · 数据库驱动封装:mysqli 预处理与 affected_rows 关闭后变 -1 的坑
数据库·mysql·php·工程实践·fengcms
YYYing.7 小时前
【Redis剑指offer系列 (二) 】Redis线程模型
数据库·redis·缓存·八股
维爱智VR认知学能7 小时前
Python SQLite本地训练记录表迁移失败回滚与事务验证
数据库·python·单元测试·sqlite·软件工程
OpenCSG8 小时前
客户案例|Dell携手OpenCSG打造AI原生超节点
数据库·人工智能·ai-native
TDengine (老段)8 小时前
TDengine IDMP ---- Excel 插件
大数据·数据库·excel·时序数据库·tdengine·涛思数据
djjjx.8 小时前
Mysql数据库基础篇(十三):图解 MySQL 索引底层原理与事务隔离级别
数据库·mysql
lusklusklusk8 小时前
图文详解:使用 Power BI Desktop 一步步创建并部署跨 Excel 与 SQL 数据的 PBIRS 报表
数据库·sql·excel