用户环境变量
umask 022
export EDITOR=vi
export ORACLE_SID=orclasm
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export ORACLE_ALERT=$ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
export SQLPATH=$ORACLE_HOME/sqlplus/admin
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" SELECT userenv('LANGUAGE') db_NLS_LANG FROM DUAL;
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'
alias sas='sqlplus / as sysdba'
windows
NLS_DATE_FORMAT=YYYY-MM-DD HH24:mi:ss
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
ORACLE10G=D:\Program files\app\oracle\product\10.2.0\db_1
ORACLE11G=D:\Program files\app\oracle\product\11.2.0.1\dbhome_1
ORACLE8I=D:\Program files\app\oracle\product\ora8i
ORACLE9I=D:\Program files\app\oracle\product\ora92
ORACLE_HOME=D:\Program files\app\oracle\product\11.2.0.1\dbhome_1
PATH=%ORACLE_HOME%\bin
TNS_ADMIN=%ORACLE_HOME%\NETWORK\ADMIN
------ cmd下设置用户环境变量:SETX
SETX Variable Value [-m]
其中-m表示为系统级(Machine environment, HKLM),默认为用户级(User, HKCU)
需要注意的是,这样设置的环境变量并不会在当前的CMD下生效,要想生效,必须重启一个CMD。
---------cmd下设置用户环境变量
SETX "NLS_DATE_FORMAT" "YYYY-MM-DD HH24:MI:SS"
SETX "NLS_LANG" "AMERICAN_AMERICA.ZHS16GBK"
SETX "ORACLE10G" "D:\Program files\app\oracle\product\10.2.0\db_1"
SETX "ORACLE11G" "D:\Program files\app\oracle\product\11.2.0.1\dbhome_1"
SETX "ORACLE8I" "D:\Program files\app\oracle\product\ora8i"
SETX "ORACLE9I" "D:\Program files\app\oracle\product\ora92"
SETX "ORACLE_HOME" "D:\Program files\app\oracle\product\11.2.0.1\dbhome_1"
SETX "TNS_ADMIN" "%ORACLE_HOME%\NETWORK\ADMIN"
SETX "Path" "%ORACLE_HOME%\bin"
SETX "VBOX_MSI_INSTALL_PATH" "D:\Program Files\Oracle\VirtualBox"
SETX "ORACLE_HOME" "D:\Program files\app\oracle\product\11.2.0.1\dbhome_1"
SETX "TNS_ADMIN" "%%ORACLE_HOME%%\network\admin"
SETX "PATH" "%path%;%%ORACLE_HOME%%\bin"
SETX "NLS_DATE_FORMAT" "YYYY-MM-DD HH24:MI:SS"
SETX "NLS_LANG" "AMERICAN_AMERICA.ZHS16GBK"
/etc/profile
cat >> /etc/profile <<"EOF"
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/19.3.0/grid
export GRID_HOME=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME/bin
EOF
日期语言环境
alter session set nls_language='SIMPLIFIED CHINESE';
alter system set nls_language='AMERICAN' scope=spfile;
------- 修改日期的显示格式
execute immediate 'alter session set NLS_DATE_FORMAT=''YYYY-MM-DD DY HH24:MI:SS''';
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile;