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