当前位置:网站首页>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:

边栏推荐
- Numpy's ndarray array Foundation
- Ttchat x Zadig open source co creates helm access scenarios, and environmental governance can be done!
- Gbase8s database into external clause
- 基于字节码的统一异常上报实践
- Gbase8s database select has order by Clause 1
- 易快报:我们用 Zadig 实现万次构建部署,聪明运维,释放开发生产力
- Pro test! Centos7 deploy PHP + spool
- ArtBench:第一个类平衡的、高质量的、干净注释的和标准化的艺术品生成数据集
- Numpy的ndarray数组基础
- Gbase8s database select has a having clause
猜你喜欢

Numpy's ndarray array Foundation

ERP编制物料清单 金蝶

Do you think people who learn machinery are terrible?

揭秘百度智能测试在测试自动执行领域实践

智能垃圾桶(四)——树莓派pico实现超声波测距(HC-SR04)

Titanium dynamic technology: our Zadig landing Road

Sofaregistry source code | data synchronization module analysis

ERP preparation of bill of materials Huaxia

Ttchat x Zadig open source co creates helm access scenarios, and environmental governance can be done!

& 3 view request message and response message in browser
随机推荐
GBase8s数据库select有ORDER BY 子句5
这个EMR-SparkSQL节点,他查询的表是不是ODPS的啊?
Gbase8s database select has order by Clause 6
Titanium dynamic technology: our Zadig landing Road
Gbase8s database select has order by Clause 4
Gbase8s database select has order by Clause 3
Jerry's about TWS pairing mode configuration [chapter]
Syntax of gbase8s database incompatible with for update clause
内插散点数据
现在怎么开户?有没有更快又安全的开通渠道
大家有没有觉得学机械的人很可怕?
&4 express框架
LM07丨细聊期货横截面策略
Gbase 8s extended external connection 1
力扣每日一题-第31天-13.罗马数组转整数
Embedded database development programming (IV) -- DDL, DML
Gbase8s database select has order by Clause 5
Weekly recommended short video: How did Einstein think?
AUTOCAD——文字显示方式、CAD怎么直接打开天正图纸
易快报:我们用 Zadig 实现万次构建部署,聪明运维,释放开发生产力