Oracle 12c新特性

阅读更多
查询所有pdb

[oracle@gj4 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 24 09:18:34 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         READ WRITE NO





切换cdb与pdb

SQL> alter session set container=drbpdb;

Session altered.

SQL> show con_name

CON_NAME

——————————

DRBPDB





SQL> alter session set container=cdb$root;

Session altered.

SQL> show con_name

CON_NAME

——————————

CDB$ROOT





在cdb中关闭和打开pdb

SQL> show pdbs



    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         READ WRITE NO

SQL> alter pluggable database drbpdb close immediate;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         MOUNTED





在cdb中打开关闭所有pdb

SQL> alter pluggable database all close immediate;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         MOUNTED

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         READ WRITE NO





cdb中新建sysdba用户

SQL> create user c##test identified by test container = all;

User created.

SQL> grant sysdba,connect ,resource to c##test container = all;

Grant succeeded.

SQL> conn c##test/test as sysdba

Connected.

SQL> show con_name

CON_NAME

——————————

CDB$ROOT



创建新pdb

SQL> create pluggable database testpdb admin user dxq identified by oracle roles=(connect,resource)

  2  file_name_convert=

  3  ('/oradata/drb/pdbseed','/oradata/drb/testpdb');



SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

———- —————————— ———- ———-

         2 PDB$SEED                       READ ONLY  NO

         3 DRBPDB                         READ WRITE NO

         4 TESTPDB                        MOUNTED



配置pdb的tns连接

Tnsnames.ora

test =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.190.147)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = testpdb)

    )

  )

listener.ora

SID_LIST_LISTENER=

(SID_LIST=

  (SID_DESC =

  (GLOBAL_DBNAME = drb)   #CDB信息

  (SID_NAME = drb)

  )

  (SID_DESC =

  (GLOBAL_DBNAME = testpdb) #testPDB信息

  (SID_NAME = drb)

  )

)

—————————————–

重启监听

—————————————–

[oracle@gj4 admin]$ sqlplus dxq/oracle@test

SQL*Plus: Release 12.2.0.1.0 Production on Fri Mar 24 13:25:11 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Fri Mar 24 2017 11:31:34 +08:00

Connected to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL> show con_name

CON_NAME

——————————

TESTPDB

你可能感兴趣的:(Oracle)