由于环境更新,Oracle版本换成19C,新建用户必须加 “C##“ ,对此默认实例为ORCLCDB。
如果想自定义用户名 我们开启PDB模式即可
先使用如下命令登入oracle,然后查询系统已有的PDB;
sqlplus / as sysdba select name from V$pdbs;
SQL> select name from V$pdbs; NAME -------------------------------------------------------------------------------- ORCLPDB1
由此可见,系统有一个ORCLPDB1容器;我们首先查询他的状态,如果没有启用,就先启用它
SQL> select name,open_mode from V$pdbs; NAME -------------------------------------------------------------------------------- OPEN_MODE ---------- ORCLPDB1 mounted
查看pdb的状态 --发现服务ORCLPDB1,处于mounted状态,此时我们只需要运行如下sql即可
alter pluggable database ORCLPDB1 open;
设置重启oracle后ORCLPDB1自动打开
alter pluggable database ORCLPDB1 save state;
最后切换到ORCLPDB1创建用户即可
alter session set container=ORCLPDB1;
开启后需要编辑tnsnames.ora文件。添加ORCLPDB1连接,复制原有内容,重新添加一份即可,例如
# 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 = chendu)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCLCDB) ) ) ORCLPDB1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = chendu)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCLPDB1) ) ) LISTENER_ORCLCDB = (ADDRESS = (PROTOCOL = TCP)(HOST = chendu)(PORT = 1521)) LISTENER_ORCLPDB1 = (ADDRESS = (PROTOCOL = TCP)(HOST = chendu)(PORT = 1521))