访问数据库的几种方法

这部分很基础,但是如果搞不清楚,对以后的学习会有影响。
SQL> select * from v$version where rownum=1;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

1.sqlplus username/password@net_service_name (这是通过网络访问)
C:\Users\Administrator>sqlplus hr/hr@55


SQL*Plus: Re lease 11.2.0.1.0 Production on 星期日 5月 17 01:14:04 2015


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

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
========================================================
C:\Users\Administrator>sqlplus


SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 01:16:47 2015


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


请输入用户名:  hr@55
输入口令:


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

================================================================

C:\Users\Administrator>sqlplus /nolog


SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 01:17:17 2015


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


SQL> conn hr/hr@55
已连接。


当然也可以过EZCONNECT连接数据库(easy  connect):

CONNECT username/password@host[:port]/service_name[/instance_name]
CONNECT username/password@[//]host[:port]/service_name





假如你连接没有成功检查一下客户端\network\admin\ sqlnet.ora下:
SQL> select * from v$version where rownum=1;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production


添加EZCONNECT:
NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT)
下面模拟不添加EZCONNECT:

通过模拟去除服务器端  \network\admin\ sqlnet.ora中 NAMES.DIRECTORY_PATH的参数EZCONNECT,客户端任然可以通过EZCO连接,这一点我不是太清楚,希望有朋友可以分享一下。

2.

[oracle@localhost ~]$ sqlplus hr/hr
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 02:12:05 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


3.
[oracle@localhost ~]$ sqlplus sys/manager as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 02:12:49 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

4.
[oracle@localhost ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 02:13:45 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
请输入用户名:  hr
输入口令: 
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

5.
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 02:15:09 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> connect hr/hr
已连接。
SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 02:15:40 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> connect sys/manager as sysdba
已连接。

此种方法是启动了sqlplus,然后通过connect连接上了数据库.


6.通过oracle提供的工具或第三方工具:
sql  developer ,pl/sql developer,toad,spotlight.......
如果通过网络连接数据库掌握了,这都是非常简单的了。

以上比较简洁的介绍了这些方法,但是并没有罗列全部,比如还有:
HOSTNAME,LDAP,NIS等方法,感兴趣可以自行实验。



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29876893/viewspace-1658103/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29876893/viewspace-1658103/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值