OracleStudy之--NLS_DATE_FORMAT

Oracle Study之--NLS_DATE_FORMAT

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊、網(wǎng)站空間、營銷軟件、網(wǎng)站建設(shè)、墨玉網(wǎng)站維護(hù)、網(wǎng)站推廣。


系統(tǒng)環(huán)境:

     操作系統(tǒng):RedHat EL6

     數(shù)據(jù)庫:    Oracle 11gR2

在RMAN中設(shè)置時(shí)間格式時(shí),報(bào)錯(cuò):


Oracle Study之--NLS_DATE_FORMAT

Oracle中 NLS_DATE_FORMAT的設(shè)置方法 

分類:
Oracle中 NLS_DATE_FORMAT的設(shè)置方法
Oracle日期格式默認(rèn)為:DD-MON-YY,以下是3種方法可以修改使之永久生效;


1、修改glogin.sql文件,這個(gè)文件的路徑為:
Windows下:
%ORACLE_HOME\sqlplus\admin\
Unix下:
$ORACLE_HOME/sqlplus/admin/
在文件中加入:
alter session set nls_date_format = 'yyyy-mm-dd hh34:mi:ss';


2、修改注冊表(windows平臺(tái))
開始-->運(yùn)行-->regedit-->HKEY_LOCAL_MACHINE-->SOFTWARE-->ORACLE-->KEY_ORADb10g_home1
新建字符串值:
NLS_DATE_FORMAT,并設(shè)置其值為:YYYY-MM-DD:HH24:MI:SS


3、修改用戶環(huán)境變量(Unix平臺(tái))
export NLS_DATE_FORMAT =AMERICAN
export NLS_DATE_FORMAT ='YYYY-MM-DD HH24:MI:SS'
RMAN會(huì)話中設(shè)置NLS_DATE_FORMAT 和NLS_LANG
run {
...........
sql 'alter session set NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS";
sql 'alter session set NLS_LANG ="AMERICAN";
...........
}

Oracle 官方解釋:


Explanation 

part1:
     NLS_DATE_FORMAT is client centric, not server centric. This way each client can see dates the way he/she needs to. For example clent in Europe is used to dates in DD/MM/YY format while clients in the US are used to MM/DD/YY. Therefore, each client needs to set NLS_DATE_FORMAT on the client box. In Windows, start regedit, go to HKEY_Local_Machine, Software, Oracle and add entry NLS_DATE_FORMAT = 'MM/DD/YYYY'. On Unix set environment variable NLS_DATE_FORMAT.

part2:
part1 is not entirely true.
     NLS_DATE_FORMAT is not that straight forward. And explanation I gave you is not entirely true. There is a lot of articles in Oracle's MetaLink on that topic. If you are MetaLink customer check http://support.oracle.com.sg/met ... OT&p_id=74375.1

     NLS_DATE_FORMAT is used if a date format mask is not specified in application code. The effective NLS_DATE_FORMAT is determined by the following (in order of precedence): 

1. Session NLS_DATE_FORMAT (via ALTER SESSION command) 
2. Client side NLS_DATE_FORMAT (from client environment variables/registry settings) 
3. Instance NLS_DATE_FORMAT (from init.ora file) 
4. Database NLS_DATE_FORMAT 


     Session NLS_DATE_FORMAT is set to client side NLS_DATE_FORMAT (explicit or implicit) ONLY if NLS_LANG is set. Another words, if NLS_LANG is set, then session NLS_DATE_FORMAT will be taken from the client. If clent NLS_LANG is set and client NLS_DATE_FORMAT is not, session NLS_DATE_FORMAT will default to DD-MON-YY (and that was exactly what you experienced). If NLS_LANG is not specified on the client side, NLS_DATE_FORMAT will be taken from instance NLS_DATE_FORMAT which is NLS_DATE_FORMAT from INIT.ORA. If NLS_DATE_FORMAT is not set in INIT.ORA, session NLS_DATE_FORMAT will default to DD-MON-YY.

當(dāng)前題目:OracleStudy之--NLS_DATE_FORMAT
文章位置:http://muchs.cn/article36/ighhpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、云服務(wù)器、企業(yè)建站、動(dòng)態(tài)網(wǎng)站、營銷型網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管