程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SyBase數據庫 >> SyBase教程 >> 訪問數據庫的幾種方法

訪問數據庫的幾種方法

編輯:SyBase教程

訪問數據庫的幾種方法


這部分很基礎,但是如果搞不清楚,對以後的學習會有影響。
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等方法,感興趣可以自行實驗。



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved