How does Oracle12c connect to CDB and PDB?

Source: Internet
Author: User

How does Oracle12c connect to CDB and PDB?


1 connect to CDB

Same as a normal instance. After specifying ORACLE_SID, you can use OS authentication or password for connection.

[Oracle @ Ora12c/] $ echo $ ORACLE_SID

Cndba

[Oracle @ Ora12c/] $ sqlplus/as sysdba

SQL * Plus: Release 12.1.0.1.0 Production onMon Apr 28 11:33:43 2014

Copyright (c) 1982,201 3, Oracle. All rights reserved.

Connected:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0-64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL> conn system/oracle

Connected.

SQL>

-- View available services in CDB:

SQL> COLUMN name FORMAT A30

SQL> SELECT name, pdb

2 FROM v $ services

3 order by name;

NAME PDB

------------------------------------------------------------

SYS $ background cdb $ ROOT

SYS $ users cdb $ ROOT

Cndba CDB $ ROOT

CndbaXDB CDB $ ROOT

Pcndba2 PCNDBA2

Pdbcndba PDBCNDBA

6 rows selected.

-- Lsnrctl can also be used to determine:

[Oracle @ Ora12c/] $ lsnrctl service

LSNRCTL for Linux: Version 12.1.0.1.0-Production on 28-APR-2014 11:35:31

Copyright (c) 1991,201 3, Oracle. All rights reserved.

Connecting to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1521 )))

Services Summary...

Service "cndba" has 1 instance (s ).

Instance "cndba", status READY, has 1 handler (s) for thisservice...

Handler (s ):

"DEDICATED" established: 0 refused: 0 state: ready

LOCAL SERVER

Service "cndbaXDB" has 1 instance (s ).

Instance "cndba", status READY, has 1 handler (s) for thisservice...

Handler (s ):

"D000" established: 0 refused: 0 current: 0 max: 1022 state: ready

DISPATCHER <machine: Ora12c, pid: 10085>

(ADDRESS = (PROTOCOL = tcp) (HOST = Ora12c) (PORT = 14696 ))

Service "pcndba2" has 1 instance (s ).

Instance "cndba", status READY, has 1 handler (s) for thisservice...

Handler (s ):

"DEDICATED" established: 0 refused: 0 state: ready

LOCAL SERVER

Service "pdbcndba" has 1 instance (s ).

Instance "cndba", status READY, has 1 handler (s) for thisservice...

Handler (s ):

"DEDICATED" established: 0 refused: 0 state: ready

LOCAL SERVER

The command completed successfully

[Oracle @ Ora12c/] $

Through these services, you can remotely connect to CDB.

-- EZCONNECT

C: \ Users \ Dave> sqlplussystem/oracle@192.168.1.10: 1521/cndba

SQL * Plus: Release 11.2.0.1.0 Production on Wednesday April 30 11:36:48 2014

Copyright (c) 1982,201 0, Oracle. All rights reserved.

Connect:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0-64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

-- Connect through TNSNAMES. ORA:

Configure tnsnames. ora as follows:

Cndba =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = cndba)

)

)

-- Connection:

C: \ Users \ Dave> sqlplussystem/oracle @ cndba

SQL * Plus: Release 11.2.0.1.0 Production on Wednesday April 30 11:40:01 2014

Copyright (c) 1982,201 0, Oracle. All rights reserved.

Connect:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0-64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

2. Switch between different iner Databases

In the 12c architecture, because CDB and PDB exist, there are many different iner, so when connecting to different container, you need to switch.

-- View the current iner:

SQL> show con_name

CON_NAME

------------------------------

CDB $ ROOT

SQL> SELECT SYS_CONTEXT ('userenv', 'Con _ name') FROM dual;

SYS_CONTEXT ('userenv', 'Con _ name ')

--------------------------------------------------------------------------------

CDB $ ROOT

SQL & gt; set lin 140

SQL> select con_id, dbid, guid, name, open_mode from v $ pdbs;

CON_ID dbid guid name OPEN_MODE

------------------------------------------------------------------------

2 4088301206 F7C1E3C96BBF0585E0430A01A8C05459 PDB $ SEED READ ONLY

3 listen 143573f7c209eb1dfc0854e0430a01a8c0b787 PDBCNDBA READ WRITE

4 1231796139 F812DE1B6A8F363AE0430A01A8C0C759 PCNDBA2 READ WRITE

-- Switch container:

SQL> alter session setcontainer = pcndba2;

Session altered.

SQL> show con_name

CON_NAME

------------------------------

PCNDBA2

3 connect to PDB

-- EZCONNECT:

C: \ Users \ Dave> sqlplussystem/oracle@192.168.1.10: 1521/pcndba2

SQL * Plus: Release 11.2.0.1.0 Production on Wednesday April 30 11:54:30 2014

Copyright (c) 1982,201 0, Oracle. All rights reserved.

Connect:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0-64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

-- TNSNAMES. ora

Add the following content to tnsnames. ora:

Pcndba =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = pcndba2)

)

)

C: \ Users \ Dave> sqlplussystem/oracle @ pcndba

SQL * Plus: Release 11.2.0.1.0 Production on Wednesday April 30 11:55:50 2014

Copyright (c) 1982,201 0, Oracle. All rights reserved.

Connect:

Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0-64bit Production

With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options

SQL>

Bytes --------------------------------------------------------------------------------------------

All rights reserved. reprinted articles are allowed, but source addresses must be indicated by links. Otherwise, the documents will be held legally responsible!

AboutDave:

Bytes --------------------------------------------------------------------------------------------

QQ: 251097186

Email: tianlesoftware@gmail.com

Blog: http://blog.csdn.net/tianlesoftware

WEAVER: http://weibo.com/tianlesoftware

Twitter: http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware

Dave's QQ group:

Bytes --------------------------------------------------------------------------------------------

Note: The relationship between tablespaces and data files must be specified for grouping. | do not add groups repeatedly.

CNDBA_1: 104207940 (full) CNDBA_2: 62697716 (full) CNDBA_3: 283816689

CNDBA_4: 391125754 CNDBA_5: 62697850 CNDBA_6: 62697977 CNDBA_7: 142216823 (full)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.