欢迎投稿

今日深度:

访问数据库的几种方法

访问数据库的几种方法


这部分很基础,但是如果搞不清楚,对以后的学习会有影响。
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: Release 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:
n罐?+懅f妠*杦秿?凞	3慲?FB8覦	1鉓$郗忽n峨⒍湑閔q゛⑺l猌e喝k?郗$>[珽閊j堑譵5喧鑦?妷锜漿觤v訚醋栯
妑?!低}髆从帧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等方法,感兴趣可以自行实验。



www.htsjk.Com true http://www.htsjk.com/sybase/19659.html NewsArticle 访问数据库的几种方法 这部分很基础,但是如果搞不清楚,对以后的学习会有影响。 SQL select * from v$version where rownum=1; BANNER ----------------------------------------------------------------------------...
评论暂时关闭