您的位置:首页 > 数据库

访问数据库的几种方法

2015-05-17 02:26 176 查看
这部分很基础,但是如果搞不清楚,对以后的学习会有影响。

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:



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

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等方法,感兴趣可以自行实验。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: