[標題]:使用Oracle Instant Client - SQLPlus
[時間]:2009-7-20
[摘要]:使用Oracle Instant Client - SQL*Plus從客戶端連接Oracle服務器。
[關鍵字]:SQL*Plus,Instant,Oracle,JDevelopers,PL/SQL
[環境]:Oracle 11g
[作者]:Winty (wintys@gmail.com) http://www.tkk7.com/wintys
[正文]:
1、下載Oracle Instant Client
服務器系統Windows Server 2003,安裝了Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 ,帶有SQL*Plus。客戶端系統Windows XP SP3,需要使用SQL*Plus對Oracle數據庫進行操作。搜索了一下,發現Oracle Instant Client(
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html)正是所需。
如果只使用SQL*Plus,則下載以下兩個包即可:
a)、Instant Client Package - Basic:
All files required to run OCI, OCCI, and JDBC-OCI applications
instantclient-basic-win32-11.1.0.6.0.zip (43,316,697 bytes)
b)、Instant Client Package - SQL*Plus:
Additional libraries and executable for running SQL*Plus with Instant Client
instantclient-sqlplus-win32-11.1.0.6.0.zip (788,050 bytes)
2、安裝配置
a、將instantclient-basic-win32-11.1.0.6.0.zip 和 instantclient-sqlplus-win32-11.1.0.6.0.zip解壓到同一目錄下(如:F:\Oracle\InstantClient)。
b、環境變量設置:
將F:\Oracle\InstantClient增加到系統環境變量
PATH中。
再添加環境變量TNS_ADMIN (admin目錄是自己新建的):
TNS_ADMIN=F:\Oracle\InstantClient\admin
可選環境變量:
NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
c、在TNS_ADMIN所指目錄F:\Oracle\InstantClient\admin下增加一個配置文件tnsnames.ora。這個文件可以直接從服務器的Oracle安裝目錄(H:\Oracle\product\11.1.0\db_1\network\admin\tnsnames.ora)下找到,直接復制過來。
tnsnames.ora:
# tnsnames.ora Network Configuration File:
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.168.1.101)
)
)
3、使用SQL*Plus:
打開cmd,輸入如下內容:
c:\>sqlplus sys/admin@orcl as sysdba
如果輸出類似如下內容,則表示連接成功:
SQL*Plus: Release 11.1.0.6.0 - Production on 星期二 7月 21 00:03:28 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
也可以這樣輸入:
c:\>sqlplus /nolog
SQL> conn sys@orcl as sysdba
輸入口令:admin
4、注意問題:
a、以sys用戶登陸后要加"as sysdba",否則可能出現如下錯誤:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
b、如果不指定tnsnames.ora,則可能出現如下錯誤:
ORA-12154: TNS: 無法解析指定的連接標識符
c、如果不需要Instant Client了,想刪除它,可能會發現無法刪除F:\Oracle\InstantClient\oci.dll。這時,只要停止msdtc服務:"net stop msdtc" ,然后再刪除即可。
posted on 2009-07-21 00:30
天堂露珠 閱讀(1835)
評論(0) 編輯 收藏 所屬分類:
Database