分类:
2012-12-13 14:25:51
在Oracle中,使用命令连接到数据库时,一般都有{
确实,当未能正确使用conect_identifier这个参数是,无情的错误提示将会把我们挡在数据库的大门外。
ORA-12154: TNS:could not resolve the connect identifier specified
其实,我们可以简单的看看sqlplus命令提供的帮助,里面有关于connect_identifier的简要说明。
@[
Example: Connect to database using Net Service Name and the database net service name is ORCL.
sqlplus myusername/mypassword@ORCL
Host specifies the host name or IP address of the database server computer.
Port specifies the listening port on the database server.
Example: Connect to database using Easy Connect and the Service name is ORCL.
sqlplus myusername/mypassword@Host/ORCL
The /NOLOG option starts SQL*Plus without connecting to a database.
可以看出,@connect_indentifier指定的不是机器名,是
$ cat /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORACLE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = demo)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORACLE)
)
)
LISTENER_ORACLE =
(ADDRESS = (PROTOCOL = TCP)(HOST = demo)(PORT = 1522))