Sqlplus 聯機文檔學習

Oracle聯機文檔

位置:http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/qstart.htm#BABFDDDG

[原文]

Starting SQL*Plus Command-line

The SQL*Plus executable is usually installed in $ORACLE_HOME/bin, which is usually included in your operating system PATH environment variable. You may need to change directory to the $ORACLE_HOME/bin directory to start SQL*Plus.

In the following examples, you are prompted to enter the database account password.

An example using an Easy Connection identifier to connect to the HR schema in the MYDB database running on mymachine is:

sqlplus hr@\"//mymachine.mydomain:port/MYDB\"

An example using a Net Service Name is:

sqlplus hr@MYDB

Net Service Names can be stored in a number of places, including Oracle Names. See the Net Services Reference Guide for more information.

[譯文]

啓動Sqlplus命令行模式:

通常情況下,Sqlplus可以執行,它的安裝目錄是$ORACLE_HOME/bin,而且在系統中設置環境變量PATH,需要將目錄改變爲$ORACLE_HOME/bin,就可以執行Sqlplus。

下面的例子,按照提示,可以輸入數據庫的帳號和口令。

這個例子在我們的機器上運行簡單的連接標識符來連接MYDB數據庫的HR模式:

sqlplus hr@\"//mymachine.mydomain:port/MYDB\" 可以使用網絡服務名稱: sqlplus hr@MYDB 網絡服務名稱能存儲一個確認點,包括Oracle數據庫名。可以查看關於網絡服務參考指導的更多信息。 [原文]

If you want to use Net Service Names configured in a local Oracle Net tnsnames.ora file, then set the environment variable TNS_ADMIN to the directory containing the tnsnames.ora file. For example, on UNIX, if your tnsnames.ora file is in /home/user1 and it defines the Net Service Name MYDB2:

TNS_ADMIN=/home/user1 export TNS_ADMIN sqlplus hr@MYDB2

This example assumes the ORACLE_HOME environment variable is set, and the $ORACLE_HOME/network/admin/tnsnames.ora or ORACLE_HOME\network\admin\tnsnames.ora file defines the Net Service Name MYDB3:

sqlplus hr@MYDB3

The TWO_TASK (on UNIX) or LOCAL (on Windows) environment variable can be set to a connection identifier. This removes the need to explicitly enter the connection identifier whenever a connection is made in SQL*Plus or SQL*Plus Instant Client. This UNIX example connects to the database known as MYDB4:

TNS_ADMIN=/home/user1 export TNS_ADMIN TWO_TASK=MYDB4 export TWO_TASK sqlplus hr

[譯文]

如果我們使用網絡服務名稱,那就需要配置Oracle的網絡文件tnsnames.ora;設置tnsnames.ora文件中的TNS_ADMIN環境變量。例如下面例子,在UNIX下,如果你的tnsnamets.ora文件設置目錄/home/user1,並且定義網絡服務名稱爲MYDB2:

TNS_ADMIN=/home/user1

export TNS_ADMIN

sqlplus hr@MYDB2

這個例子指出ORACLE_HOME環境變量已經被設置,並且定義$ORACLE_HOME/network/admin/tnsnames.ora or ORACLE_HOME\network\admin\tnsnames.ora中的網絡服務名稱爲MYDB3:

sqlplus hr@MYDB3

在Unix和Windows下設置環境變量爲確認連接標識符。當我們通過Sqlplus連接Oracle數據庫時,需要確認連接標識符,這個UNIX例子中,連接的數據庫被命名爲MYDB4:

TNS_ADMIN=/home/user1

export TNS_ADMIN

TWO_TASK=MYDB4

export TWO_TASK

sqlplus hr

[原文]

To start SQL*Plus and connect to the default database

  1. Open a UNIX or a Windows terminal and enter the SQL*Plus command:

    sqlplus
  2. When prompted, enter your Oracle Database username and password. If you do not know your Oracle Database username and password, ask your Database Administrator.

  3. Alternatively, enter the SQL*Plus command in the form:

    sqlplus username

    You are prompted to enter your password.

  4. SQL*Plus starts and connects to the default database.

    Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands at the SQL> prompt.

To start SQL*Plus and connect to a database other than the default

Open a UNIX or a Windows terminal and enter the SQL*Plus command:

sqlplus username@connect_identifier

You are prompted to enter your password.

[譯文]

啓動Sqlplus連接默認的數據庫

1. 打開UNIX和Windows系統中的終端窗口,輸入Sqlplus命令:

sqlplus

2. 當提示符出現,輸入Oracle數據庫的用戶名和密碼。如果不確定用戶名和密碼,請向數據庫管理員詢問。

3. 也可以在Sqlplus命令行提示符下輸入命令:

sqlplus username

根據提示,輸入密碼。

4.Sqlplus啓動後,連接到默認的數據庫上。

現在就可以在Sqlplus提示符>下輸入Sql,PL/SQL和Sqlplus命令了。

如何啓動Sqlplus連接到其它默認的數據庫:

sqlplus username@connect_identifier 然後根據提示輸入密碼即可。 [原文]

Starting SQL*Plus Instant Client

SQL*Plus Instant Client is the SQL*Plus command-line without the need to install Oracle Database. For information about using it, see Starting SQL*Plus Command-line.

Because SQL*Plus Instant Client does not include a database, it is always 'remote' from any database server. To connect to a database you must specify the database using an Oracle Net connection identifier.

If TNS_ADMIN is not set, then an operating system dependent set of directories is examined to find tnsnames.ora. This search path includes looking in the directory specified by the ORACLE_HOME environment variable for network/admin/tnsnames.ora. This is the only reason to set the ORACLE_HOME environment variable for SQL*Plus Instant Client. If ORACLE_HOME is set when running Instant Client applications, it must be set to a directory that exists.

[譯文]

啓動Sqlplus安裝客戶端

當Oracle數據庫沒有安裝Sqlplus時,就需要安裝Sqlplus安裝客戶端;

因爲Sqlplus安裝客戶端不包含在數據庫中,它通常是通過其它數據庫“遠程”連接。所以連接到一個數據庫必須指定數據庫的網絡連接標識符。

當操作系統依靠設置、檢查的tnsnames.ora沒有設置TNS_ADMIN,這個搜索過程包括目錄的ORACLE_HOMT環境變量中的network/admin/tnsnames.ora.這是對Sqlplus安裝客戶端唯一進行設置的ORACLE_HOME環境變量。所以,如果ORACLE_HOME在安裝運行客戶端應用程序的過程時是設置了,那麼它必須被設置目錄和存在。

[原文]

Connecting to a Different Database

From an existing command-line session, enter a CONNECT command in the form:

SQL> connect username@connect_identifier

You are prompted to enter your password.

[譯文]

如何連接不同的數據庫

從已經連接的會話中退出,然後鍵入“CONNECT命令:

SQL> connect username@connect_identifier 然後根據提示輸入密碼。

(待續……)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章