Chinaunix首页 | 论坛 | 博客
  • 博客访问: 281698
  • 博文数量: 38
  • 博客积分: 706
  • 博客等级: 上士
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-05 09:09
文章分类

全部博文(38)

文章存档

2013年(23)

2012年(15)

我的朋友

分类:

2012-12-13 14:25:51

在Oracle中,使用命令连接到数据库时,一般都有{[/][@]的提示,其中的username和password毋庸置疑的是用户名和密码,而connect_indentifier则让很多人很困惑,究竟这个地方需要怎么才算是正确填写呢。

确实,当未能正确使用conect_identifier这个参数是,无情的错误提示将会把我们挡在数据库的大门外。

    ORA-12154: TNS:could not resolve the connect identifier specified

其实,我们可以简单的看看sqlplus命令提供的帮助,里面有关于connect_identifier的简要说明。

    can be in the form of Net Service Name  or Easy Connect.

       @[ | [//]Host[:Port]/]

    is a simple name for a service that resolves to a connect descriptor.

        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.

    specifies the service name of the database you want to access.

    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指定的不是机器名,是,这个定义在tnsnames.ora中完成的
$ 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))

阅读(2898) | 评论(0) | 转发(0) |
0

上一篇:Linux system函数

下一篇:system函数

给主人留下些什么吧!~~