sqlplus使用(一)

一,sqlplus 环境变量
sqlplus的环境变量(来自SQL*Plus? User‘s Guide and Reference Release 11.2
Parameter or Variable Description

LD_LIBRARY_PATH

Environment variable to specify the path used to search for libraries on UNIX and Linux. The environment variable may have a different name on some operating systems, such as DYLD_LIBRARY_PATH on Apple Mac OSLIBPATH on IBM/AIX-5L, and SHLIB_PATH on HP-UX. Not applicable to Windows operating systems.

Example

$ORACLE_HOME/lib 

LOCAL

Windows environment variable to specify a connection string. Performs the same function as TWO_TASK on UNIX.Windows平台下的环境变量。类似于Unix中的TWO_TASK

NLS_LANG

Environment variable to specify globalization behavior.

Example

american_america.utf8

ORACLE_HOME

Environment variable to specify where SQL*Plus is installed. It is also used by SQL*Plus to specify where message files are located.

Examples:

d:\oracle\10g
/u01/app/oracle/product/v10g
ORA_EDITION
指定版本

Environment variable to specify the database edition to use. If you specify the edition with the CONNECT or SQLPLUS command option, edition=value, it is used instead of ORA_EDITION. If no edition is specified in either the CONNECT or SQLPLUS command option, or in ORA_EDITION, SQL*Plus connects to the default edition.

ORA_NLS10

Environment variable to specify the locations of the NLS data and the user boot file in SQL*Plus 10.2. The default location is $ORACLE_HOME/nls/data. In a system with both Oracle9i and 10g, or a system under version upgrade, you should set ORA_NLS10 for Oracle 10g and set ORA_NLS33 for 9i. The default NLS location in 9i was $ORACLE_HOME/common/nls/admin/data.

ORACLE_PATH
 
在sqlplus执行@sql时也从这个目录中找
 
和下面的SQLPATH类似,SQLPATH多一个登陆加载的功能

Environment variable to specify the location of SQL scripts. If SQL*Plus cannot find the file in ORACLE_PATH, or if ORACLE_PATH is not set, it searches for the file in the current working directory.

Not applicable to Windows
 
指定执行sql脚本的目录,如果不指定默认为当前工作目录

ORACLE_SID

Environment variable to specify the database instance, optional

PATH

Environment variable to specify the path to search for executables, and DLLs in Windows. Typically includes ORACLE_HOME/bin

SQLPATH
 
设置在sqlplus启动是加载login.sql文件的位置,如表格后面
 
在sqlplus执行@sql时也从这个目录中找

Environment variable or Windows registry entry to specify the location of SQL scripts. SQL*Plus searches for SQL scripts, including login.sql, in the current directory and then in the directories specified by SQLPATH, and in the subdirectories of SQLPATH directories. SQLPATH is a colon separated list of directories. There is no default value set in UNIX installations.

In Windows, SQLPATH is defined in a registry entry during installation. For more information about the SQLPATH registry entry, see SQLPATH Registry Entry.

TNS_ADMIN
指定tnsnames.ora的路径,如果不指定默认使用$ORACLE_HOME/network/admin

Environment variable to specify the location of the tnsnames.ora file. If not specified, $ORACLE_HOME/network/admin is used

Example

h:\network 
/var/opt/oracle

TWO_TASK 

UNIX environment variable to specify a connection string. Connections that do not specify a database will connect to the database specified in TWO_TASK.
指定默认连接的数据库,后面没有加相应的字符串的话,就去连接TWO_TASK指定的字符串

Example

TWO_TASK=MYDB
export TWO_TASK
sqlplus hr

is the same as:

sqlplus hr@MYDB
取消环境变量
export TWO_TASK=‘‘

SQLPATH变量;
设置SQLPATH变量路径 找到用户概要文件login.sql
export SQLPATH=/dsg/sql
vi login.sql
set long 80
set newpage 0
set feedback on
set define on
set serveroutput on
set termout on
set time off
set timing on
set verify on     
set linesize 80
set pagesize 30
set sqlprompt "_USER‘@‘_CONNECT_IDENTIFIER _DATE>"
alter session set nls_date_format=‘YYYY-MM-DD HH24:MI:SS‘;
 
当启动sqlplus的时候会自动加载SQLPATH目录下的login.sql文件
 
二,保存环境变量
 
STORE SET file_name
START file_name
或者@file_name
 
三,安装sqlplus帮助
 

Running the hlpbld.sql Script to Install Command-line Help

Run the provided SQL script, HLPBLD.SQL, to load command-line help.

  1. Log in to SQL*Plus as the SYSTEM user with:

    SQLPLUS SYSTEM
    

    You are prompted to enter the password you have defined for the SYSTEM user.

  2. In UNIX run the SQL script, HLPBLD.SQL, from SQL*Plus with:

    @$ORACLE_HOME/sqlplus/admin/help/helpus.sql  unix小写
    

    In Windows run the SQL script, HLPBLD.SQL, from SQL*Plus with:

    @ORACLE_HOME\SQLPLUS\ADMIN\HELP\HLPBLD.SQL HELPUS.SQL
    

    The HLPBLD.SQL script creates and loads the help tables.

Running the helpdrop.sql Script to Remove Command-line Help

Run the provided SQL script, HELPDROP.SQL, to remove the command-line help.

  1. Log in to SQL*Plus as the SYSTEM user with:

    SQLPLUS SYSTEM
    

    You are prompted to enter the password you have defined for the SYSTEM user.

  2. In UNIX run the SQL script, HELPDROP.SQL, from SQL*Plus with:

    @$ORACLE_HOME/sqlplus/admin/help/helpdrop.sql
    

    In Windows run the SQL script, HELPDROP.SQL, from SQL*Plus with:

    @ORACLE_HOME\SQLPLUS\ADMIN\HELP\HELPDROP.SQL
    

    The HELPDROP.SQL script drops the help tables, and then disconnects.

脚本说明:
 
  • HLPBLD.SQL -删除并创建新的帮助表

  • HELPDROP.SQL - 删除存在的帮助表

  • HELPUS.SQL -向帮助表中插入数据

sqlplus使用(一),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。