oracle12c我已经用了两年了,去现场安装等等,培训新人等等,很多次,用实际经验告诉你。首先思考一下,别名是什么,SID是什么。连接的时候别名、SID、和IP地址一个不能少,而且由于12c是为云计算来准备的,它也是一个容器的概念,最大容器依然是:ORCL,然后才是:PDBORCL,你说的PDB有没有SID,是有的,安装填写各类信息的步骤后阶段中,就有提示的,那里是默认的,连接的时候你没说清楚是用来登录数据库还是用来连接什么软件平台,如果是数据库,别名,IP,SID都要,如果是平台软件,那就要看你使用的平台软件了,它使用的脚本是以什么为依据,但不管怎样,其实服务名就是SID,别搞混了。
有问题再留言吧。
1 连接到CDB
和普通实例一样的连接。 指定ORACLE_SID 以后可以使用OS认证,也可以使用密码进行连接。
[oracle@Ora12c /]$ echo $ORACLE_SID
cndba
[oracle@Ora12c /]$ sqlplus / as sysdba
SQLPlus: Release 121010 Production onMon Apr 28 11:33:43 2014
Copyright (c) 1982, 2013, Oracle All rights reserved
Connected to:
Oracle Database 12c Enterprise EditionRelease 121010 - 64bit Production
With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options
SQL> conn system/oracle
Connected
SQL>
--查看CDB中可用的service:
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 也可以判断:
[oracle@Ora12c /]$ lsnrctl service
LSNRCTL for Linux: Version 121010 -Production on 28-APR-2014 11:35:31
Copyright (c) 1991, 2013, Oracle All rights reserved
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary
Service "cndba" has 1instance(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 1instance(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 1instance(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 1instance(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 /]$
通过这些service,就可以远程连接CDB。
--EZCONNECT
C:\Users\Dave>sqlplussystem/oracle@192168110:1521/cndba
SQLPlus: Release 112010 Production on 星期三 4月 30 11:36:48 2014
Copyright (c) 1982, 2010, Oracle All rights reserved
连接到:
Oracle Database 12c Enterprise EditionRelease 121010 - 64bit Production
With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options
SQL>
--通过TNSNAMESORA连接:
在tnsnamesora 中配置如下:
cndba =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192168110)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cndba)
)
)
--连接:
C:\Users\Dave>sqlplussystem/oracle@cndba
SQLPlus: Release 112010 Production on 星期三 4月 30 11:40:01 2014
Copyright (c) 1982, 2010, Oracle All rights reserved
连接到:
Oracle Database 12c Enterprise EditionRelease 121010 - 64bit Production
With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options
SQL>
2 在不同Container database中切换
在12c的架构中,因为有CDB和 PDB的存在,所以会有很多不同的container,所以在连接到不同的container时,就需要进行切换。
--查看当前的container:
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> 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 426143573F7C209EB1DFC0854E0430A01A8C0B787 PDBCNDBA READ WRITE
4 1231796139 F812DE1B6A8F363AE0430A01A8C0C759 PCNDBA2 READ WRITE
--切换container:
SQL> alter session setcontainer=pcndba2;
Session altered
SQL> show con_name
CON_NAME
------------------------------
PCNDBA2
3 连接到PDB
--EZCONNECT:
C:\Users\Dave>sqlplussystem/oracle@192168110:1521/pcndba2
SQLPlus: Release 112010 Production on 星期三 4月 30 11:54:30 2014
Copyright (c) 1982, 2010, Oracle All rights reserved
连接到:
Oracle Database 12c Enterprise EditionRelease 121010 - 64bit Production
With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options
SQL>
--TNSNAMESora
在tnsnamesora 中添加如下内容:
pcndba =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192168110)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pcndba2)
)
)
C:\Users\Dave>sqlplussystem/oracle@pcndba
SQLPlus: Release 112010 Production on 星期三 4月 30 11:55:50 2014
Copyright (c) 1982, 2010, Oracle All rights reserved
连接到:
Oracle Database 12c Enterprise EditionRelease 121010 - 64bit Production
With the Partitioning, OLAP, AdvancedAnalytics and Real Application Testing options
SQL>
-- Generate xml file of pdb
BEGIN
DBMS_PDBRECOVER(PDB_DESCR_FILE => '/yxq5/lomon/ODBA_AO_011_011xml',
PDB_NAME => 'ODBA_AO_011_011',
FILENAMES => '/yxq5/lomon');
END;
/
-- Check compatibility of pdb
SET SERVEROUTPUT ON
DECLARE
theResult BOOLEAN;
BEGIN
theResult := DBMS_PDBcheck_plug_compatibility(
pdb_descr_file => '/yxq5/lomon/ODBA_AO_011_011xml',
pdb_name => 'ODBA_AO_011_011');
IF theResult THEN
DBMS_OUTPUTPUT_LINE('PDB is compatible');
ELSE
DBMS_OUTPUTPUT_LINE('PDB is not compatible');
END IF;
END;
/
-- Create Pluggable Database
CREATE PLUGGABLE DATABASE ODBA_AO_011_011 USING '/yxq5/lomon/ODBA_AO_011_011xml' NOCOPY;
ALTER PLUGGABLE DATABASE ODBA_AO_011_011 open;
SELECT name, con_id FROM v$pdbs WHERE name='ODBA_AO_011_011';
-- Re-create Temporary Tablespace
SELECT property_name, property_value FROM database_properties WHERE property_name LIKE ‘%TEMP%’;
SELECT file_name FROM dba_temp_files;
CREATE TEMPORARY TABLESPACE temp1 TEMPFILE '/u01/app/oracle/oradata/cdb3/datafile/pdb1_temp01dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp1;
DROP TEMPORARY TABLESPACE TEMP;
SELECT FROM PDB_PLUG_IN_VIOLATIONS;
以下关于PDB数据库描述正确的是:
APDB数据库是一级蛋白质数据库
BPDB数据库存储大分子的3D结构
CPDB数据库里既包含蛋白质的3D结构,也包含核酸的3D结构,以及二者的复合体结构
DPDB数据库里只包含实验方法解析的大分子3D结构
EPDB数据库是二级蛋白质数据库
FPDB数据库只储存蛋白质分子的3D结构
GPDB数据库里既包含实验方法解析的大分子3D结构,也包含计算机预测结构模型
H、X射线衍射法解析的蛋白质3D结构不能提交到PDB数据库
正确答案:PDB数据库是一级蛋白质数据库;PDB数据库存储大分子的3D结构;PDB数据库里既包含蛋白质的3D结构,也包含核酸的3D结构,以及二者的复合体结构;PDB数据库里只包含实验方法解
开始菜单里输入cmd回车,输入sqlplus system/密码@数据库实例名 as sysdba回车,连接成功
这里的密码是创建数据库实例时指定的,数据库实例名需要在本机有配置,如果是在DB服务器上执行,实例名的问题就不用管了。
通过配置本地数据库的tns配置文件实现:
去oracle安装目录下oracle\product\1020\db_2\NETWORK\ADMIN\ 找到tnsnamesora,用记事本打开,里边有远程数据库的tns连接配置串如下
ORCL23 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192168323)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ORCL)
)
)
添加好ip、端口和目标数据库的实例名(SID),然后确保tns名称(ORCL23)在整个文档中唯一,保存后打开数据库连接工具,输入远程数据库上的用户名密码,选择数据库对象为你配置的连接名就可以了
以上就是关于oracle12C安装完成后,尝试用PLSQL连接PDB数据库,发现个问题PDB有没有SID使用服务名来连接还是用SID全部的内容,包括:oracle12C安装完成后,尝试用PLSQL连接PDB数据库,发现个问题PDB有没有SID使用服务名来连接还是用SID、如何配置Hibernate连接oracle12c 的PDB和CDB数据库、Oracle 19c多租户:若只有pdb数据库文件,如何将PDB插入到CDB等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)