Oracle12c中scott用户的创建方法

1 启动数据库监听

[oracle@localhost ~]$ lsnrctl start

2 进入SQLPLUS,连接到CDB数据库,启动CDB实例

[oracle@localhost ~]$ sqlplus / as sysdba
[oracle@localhost ~]$ startup

3 查看PDB数据库

SQL> select name from v$pdbs;

NAME
------------------------------
PDB$SEED
PDBORCL

4 查看PDB数据库服务

SQL> select name, pdb from v$services;

NAME
----------------------------------------------------------------
PDB
------------------------------
pdborcl.localdomain
PDBORCL

orclXDB
CDB$ROOT

orcl.localdomain
CDB$ROOT


NAME
----------------------------------------------------------------
PDB
------------------------------
SYS$BACKGROUND
CDB$ROOT

SYS$USERS
CDB$ROOT

可以看到PDBORCL对应的服务名为pdborcl.localdomain。
5 修改tnsnames.ora文件,添加如下内容:
(tnsnames.ora位于$ORACLE_HOME/network/admin目录下)

PDBORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdborcl.localdomain)
    )
  )

6 启动PDBORCL数据库并连接
(注:这里的admin为sys用户的密码,应该修改成你安装Oracle时候设定的密码)

SQL> alter session set container = PDBORCL;
SQL> startup
SQL> conn sys/admin@pdborcl as sysdba

7 创建scott用户并连接

SQL> create user scott identified by tiger;
SQL> grant connect,resource to scott;
SQL> grant unlimited tablespace to scott;
QL> conn scott/tiger@pdborcl

然后就可以使用scott用户在PDB数据库容器中和Oracle12c之前的数据库一样进行操作了!

你可能感兴趣的:(#,数据库)