访问数据库的几种方法

发表于:2015-11-24 09:26

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:Diy_os    来源:51Testing软件测试网采编

  这部分很基础,但是如果搞不清楚,对以后的学习会有影响。
  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,客户端任然可以通过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等方法,感兴趣可以自行实验。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号