第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)                     
总结

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

相关推荐
ClouGence7 小时前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神9 小时前
三、用户与权限管理
数据库·mysql
麦聪聊数据1 天前
数据服务化时代:企业数据能力输出的核心路径
数据库
shushangyun_1 天前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
DARLING Zero two♡1 天前
【MySQL数据库】数据类型与表约束
数据库·mysql
曹牧1 天前
Oracle EXPLAIN PLAN
数据库·oracle
BD_Marathon1 天前
SQL学习指南——视图
数据库·sql
活宝小娜1 天前
mysql详细安装教程
数据库·mysql·adb
贤时间1 天前
codex 助力oracle ebs 开发
数据库·oracle
秉承初心1 天前
PostgreSQL 数据性能瓶颈突破实战
数据库·postgresql·oracle