訪問資料庫的幾種方法

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



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29876893/viewspace-1658103/,如需轉載,請註明出處,否則將追究法律責任。

相關文章