当前位置:网站首页>How to create new user for ORACLE 19c (CDB & PDB)
How to create new user for ORACLE 19c (CDB & PDB)
2022-06-29 11:37:00 【梦想家DBA】
ORACLE 19c新建用户
数据据库、用户、CDB与PDB之间的关系

通常在CDB上建立的用户是common user,新建用户名前要加C##。在PDB上创建的用户是local user。
在CDB上创建用户
1.Guarante this action under the CDB enviroment.
[[email protected] ~]$ sqlplus system/system as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 29 10:12:29 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select name,cdb from v$database;
NAME CDB
--------- ---
ORCLCDB YES
2. Create New User
SQL> create user C##test identified by testpass;
User created.
3.setting authority
SQL> grant dba,connect,resource,create view to C##test;
Grant succeeded.
SQL> grant create session to C##test;
Grant succeeded.
SQL> grant select any table to C##test;
Grant succeeded.
SQL> grant update any table to C##test;
Grant succeeded.
SQL> grant insert any table to C##test;
Grant succeeded.
SQL> grant delete any table to C##test;
Grant succeeded.
4. Drop user
SQL> drop user C##test cascade;
User dropped.
SQL>
Create new user on PDB
- check the PDB name
SQL> select pdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
PDB_ID
----------
PDB_NAME
--------------------------------------------------------------------------------
DBID STATUS CREATION_SCN
---------- ---------- ------------
3
ORCLPDB1
634705280 NORMAL 2156143
2
PDB$SEED
1473614105 NORMAL 2014329
PDB_ID
----------
PDB_NAME
--------------------------------------------------------------------------------
DBID STATUS CREATION_SCN
---------- ---------- ------------
SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
CON_ID DBID
---------- ----------
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
2 1473614105
PDB$SEED
READ ONLY
3 634705280
ORCLPDB1
READ WRITE
CON_ID DBID
---------- ----------
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
Local User PDB Name is ORCLPDB1
Enter into the PDB enviroment
SQL> alter session set container=ORCLPDB1;
SQL> alter session set container=ORCLPDB1
2 ;
Session altered.New User
SQL> create user test2 identified by test2pass;
User created.
SQL> Setting authority
grant dba,connect,resource,create view to test2;
grant select any table to test2;
grant update any table to test2;
grant insert any table to test2;
grant delete any table to test2;
grant create session to test2;Setting the TNS
If not setting the TNS, it will be failed . error message is user/password error , due to the user on CDB defaultly. need to change the file tnsname.ora on remote linux oracle path network/admin(/opt/oracle/product/19c/dbhome_1/network/admin)

# tnsnames.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCLCDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLCDB)
)
)
LISTENER_ORCLCDB =
(ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
ORCLPDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLPDB1)
)
)
LISTENER_ORCLPDB1 =
(ADDRESS = (PROTOCOL = TCP)(HOST = MaxwellDBA)(PORT = 1521))
Login user:

边栏推荐
猜你喜欢

What are outer chain and inner chain?
![[pbootcms模板]作文网站/文档下载网站源码](/img/6e/51bbb4ce961defa4abd098ff3af21f.jpg)
[pbootcms模板]作文网站/文档下载网站源码

Wonderful! Miaoying technology fully implements Zadig to help container construction, and fully embraces kubernetes and Yunyuan

又一所“省会大学”,来了!

SOFARegistry 源码|数据同步模块解析

基于字节码的统一异常上报实践

ERP Kingdee for preparing BOM

Go高级工程师必修课 | 真心建议你来听听,别错过~

嵌入式数据库开发编程(四)——DDL、DML

论文复现——AC-FPN:Attention-guided Context Feature Pyramid Network for Object Detection.
随机推荐
Codeforces Round #803 (Div. 2)
地球观测卫星数据
What are outer chain and inner chain?
GBase8s数据库与 FOR UPDATE 子句不兼容的语法
对p值的理解
GBase8s数据库select有ORDER BY 子句1
Zhengda futures liu4 data integration
嵌入式数据库开发编程(四)——DDL、DML
Serving millions of developers, the first techo day Tencent technology open day released 7 "lightweight" products
& 3 view request message and response message in browser
Wonderful! Miaoying technology fully implements Zadig to help container construction, and fully embraces kubernetes and Yunyuan
SOFARegistry 源码|数据同步模块解析
ERP编制物料清单 华夏
ArtBench:第一个类平衡的、高质量的、干净注释的和标准化的艺术品生成数据集
What is the main account of Chia Tai futures used for 4 quotation software?
面试突击61:说一下MySQL事务隔离级别?
GBase8s数据库INTO TEMP 子句创建临时表来保存查询结果。
LM07丨细聊期货横截面策略
Pangolin编译error: ‘numeric_limits’ is not a member of ‘std’
Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?