1. 程式人生 > >ORA-00972: identifier is too long報錯的另外一種原因

ORA-00972: identifier is too long報錯的另外一種原因

ORA-00972: identifier is too long這個錯誤最普通的原因就是欄位太長了。

但是還有一種其他的情況:

不知道你是否遇到過這樣的情況,一個sql語句,在plsqldeveloper中可以執行,但是在sqlplus中執行就報錯ORA-00972: identifier is too long

這是因為字符集的問題。

看下面的例子:

SQL> SELECT 
  2  a.COLUMN_NAME 欄位名,
  3  DATA_TYPE||
  4  decode(DATA_TYPE,'DATE','','CLOB','','BLOB','','BFILE','','FLOAT','','LONGRAW','','LONG','','RAW','(' || TO_CHAR(DATA_LENGTH) || ')',
  5  (decode(SIGN(instr(DATA_TYPE,'CHAR')),1,'('|| TO_CHAR(DATA_LENGTH)||')',
  6  (decode(SUBSTR(DATA_TYPE,1,9),'TIMESTAMP','',
  7  (decode(NVL(DATA_PRECISION, -1), -1,'',
  8  (decode(nvl(DATA_SCALE, 0), 0,'('||
  9  to_char(DATA_PRECISION)||')','('||
 10  to_char(DATA_PRECISION)||','||
 11  to_char(DATA_SCALE) || ')'))))))))) as 欄位型別,
 12  b.comments 註釋
 13  FROM ALL_TAB_COLUMNS a,
 14       all_col_comments b
 15  WHERE b.table_name=a.TABLE_NAME
 16  and a.OWNER=b.owner
 17  and a.COLUMN_NAME=b.COLUMN_NAME
 18  and a.TABLE_NAME =upper('gw')
 19  AND a.OWNER =upper('sys')
 20  ORDER BY COLUMN_ID;
b.comments 注重
    *
ERROR at line 12:
ORA-00972: identifier is too long

這個語句在plsqldeveloper中就可以執行,不報錯。

如果設定環境變數:

[[email protected] dbs]$ export NLS_LANG='american_america.AL32UTF8'

再次執行查詢,就不報錯了:

SQL> SELECT 
  2  a.COLUMN_NAME 欄位名,
  3  DATA_TYPE||
  4  decode(DATA_TYPE,'DATE','','CLOB','','BLOB','','BFILE','','FLOAT','','LONGRAW','','LONG','','RAW','(' || TO_CHAR(DATA_LENGTH) || ')',
  5  (decode(SIGN(instr(DATA_TYPE,'CHAR')),1,'('|| TO_CHAR(DATA_LENGTH)||')',
  6  (decode(SUBSTR(DATA_TYPE,1,9),'TIMESTAMP','',
  7  (decode(NVL(DATA_PRECISION, -1), -1,'',
  8  (decode(nvl(DATA_SCALE, 0), 0,'('||
  9  to_char(DATA_PRECISION)||')','('||
 10  to_char(DATA_PRECISION)||','||
 11  to_char(DATA_SCALE) || ')'))))))))) as 欄位型別,
 12  b.comments 註釋
 13  FROM ALL_TAB_COLUMNS a,
 14       all_col_comments b
 15  WHERE b.table_name=a.TABLE_NAME
 16  and a.OWNER=b.owner
 17  and a.COLUMN_NAME=b.COLUMN_NAME
 18  and a.TABLE_NAME =upper('gw')
 19  AND a.OWNER =upper('sys')
 20  ORDER BY COLUMN_ID;


欄位名
------------------------------
欄位型別
--------------------------------------------------------------------------------
註釋
--------------------------------------------------------------------------------
NAME
CLOB

還有一種解決方法,就是將漢字改成英文。

[[email protected] dbs]$ export NLS_LANG=

SELECT 
a.COLUMN_NAME 欄位名,
DATA_TYPE||
decode(DATA_TYPE,'DATE','','CLOB','','BLOB','','BFILE','','FLOAT','','LONGRAW','','LONG','','RAW','(' || TO_CHAR(DATA_LENGTH) || ')', ')',
(decode(SIGN(instr(DATA_TYPE,'CHAR')),1,'('|| TO_CHAR(DATA_LENGTH)||')',
(decode(SUBSTR(DATA_TYPE,1,9),'TIMESTAMP','',
(decode(NVL(DATA_PRECISION, -1), -1,'',
(decode(nvl(DATA_SCALE, 0), 0,'('||
to_char(DATA_PRECISION)||')','('||
to_char(DATA_PRECISION)||','||
to_char(DATA_SCALE) || ')'))))))))) as aaaaaaaaaaaaaaaaaa,
b.comments 註釋
FROM ALL_TAB_COLUMNS a,
     all_col_comments b
WHERE b.table_name=a.TABLE_NAME
 16  and a.OWNER=b.owner
 17  and a.COLUMN_NAME=b.COLUMN_NAME
 18  and a.TABLE_NAME =upper('gw')
 19  AND a.OWNER =upper('sys')
 20  ORDER BY COLUMN_ID;


?????????
------------------------------
AAAAAAAAAAAAAAAAAA
--------------------------------------------------------------------------------
?????
--------------------------------------------------------------------------------
NAME
CLOB

如需轉載,請註明出處:http://blog.csdn.net/nanaranran/article/details/22038291

相關推薦

ORA-00972: identifier is too long另外原因

ORA-00972: identifier is too long這個錯誤最普通的原因就是欄位太長了。 但是還有一種其他的情況: 不知道你是否遇到過這樣的情況,一個sql語句,在plsqldeveloper中可以執行,但是在sqlplus中執行就報錯ORA-00972: i

超過 Oracle 的長度限制 ORA-00972: identifier is too long

對映的列名 超過了Oracle本身設定的30個字元 修改列名,使長度低於30個字元就ok。 <result column="AR_RESUMECOPY_FRIST_WORKLOC_CITY_" property="resumeCopy.firstWorkingLoca

Hibernate(oracle)下的ORA:A-00972 identifier is too long提示

今天執行一個程式時,出現了這個提示:ORA:A-00972 identifier is too long 問題出在XXX.hbm.xml中相對應表名(table)的最大長度不能超過30 mark一下,又積累了一點 9i參考的中: "If you specify a name

Unity Android IL2CPP 編譯可能原因

Unity 版本 5.6.6f2 在使用 Android 的 IL2CPP 時,發生編譯報錯,報錯內容如下所示: stdout: IL2CPP error (no further information about what managed code was being co

CMD終端關於pip,scrapy處理方法

CMD終端關於pip報錯,scrapy報錯的一種處理方法 如果在終端輸入pip,或scrapy,報如下錯誤: Fatal error in launcher: Unable to create process using '"' 這通常是因為你的電腦裝了兩個版本的python(python2.x

MySQL 8.0 Identifier name 'ix_xxx' is is too long

某日在測試庫中新加索引報錯: Identifier name 'ix_orgid_warehouseid_businessType_orderCreateTime_state_ordertype' is

MySQL 8.0 Identifier name 'ix_xxx' is is too long

某日在測試庫中新加索引報錯: Identifier name 'ix_orgid_warehouseid_businessType_orderCreateTime_state_ordertype' is too long CREATE INDEX ix_orgid_warehouseid_bu

IdeaCommand line is too long

文件夾 prop 報錯 class nbsp gpo 問題 line per 需要在該項目文件夾下.idea/workspace.xml中添加 <component name="PropertiesComponent"> ... <propert

idea:Error running $classname: Command line is too long. Shorten command line for $classname.

9.png rop line too long component 我只 ima bsp 選擇 Command line is too long 打印的變量太長了,超過了限制,這都會報錯...我只想知道idea基於什麽原理會報這個錯... 解決 1.按照提示修改該類的

ideaError running $classname: Command line is too long. Shorten command line for $classname.

之所以出現這個原因是一般是因為列印的環境變數太長了,超過了限制,可以嘗試以下方案: 1.按照提示修改該類的配置,選擇jar manifest(每個報錯的類都需要注意設定,專案的.idea/workspace.xml有這個選項,可以修改預設值,這樣就不用每次更改)  2.在專案的.idea/w

專案在idea中報Command line is too long.

Command line is too long. Shorten command line for SessionAnalysisJob or also for Application default

IDEA啟動Springbootcommand line is too long問題解決

long run before XML highlight dea 解決 provision too 1、在工作空間下找到 .idea/workspace.xml 2、查找<component name="PropertiesComponent">,並在該元素

Idea debug時報:Command line is too long

分享圖片 http prop 解決 mman 分享 方法 pat path 問題:git pull下的項目,debug時,報錯如下圖 解決方法 在項目/.idea/workspace.xml文件中添加一行代碼如下 <component name="Prop

微信支付 WeixinJSBridge is not defined

res 問題 出錯 segment problem 分享 window 目前 == 我沒有用到微信JS-SDK或者接口都正確返回預支付id都正確, 為什麽會報這個錯呢?答: 微信內置瀏覽器會有WeixinJSBridge ,但是需要一定的加載時間。 我使用了微

關於vue,webpack 中 “exports is not defined”

bpa set 設置 webp fine ebp nts modules doc vue項目npm run dev 後項目報錯 : 提示 “exports is not defined”。 導致這個問題是因為balbel的配置文件.babelrc的問題: { "p

Docker隨筆:Hyper-V PowerShell Module is not available解決方法

eas 詳細 返回 create err 虛擬 releases mod doc 當在win10使用docker-machine創建Hyper-v虛擬機時,返回了一個錯誤”Error with pre-create check: "Hyper-V PowerShell Mo

IAR 9+ 編譯 TI CC2541 出現 Segment ISTACK (size: 0xc0 align: 0) is too long for segment definition.

def 什麽 connect 例程 ini zha con sta swe IAR 9+ 編譯 TI CC2541 出現 Segment ISTACK (size: 0xc0 align: 0) is too long for segment definition. Seg

idea Command line is too long問題解決

  Idea啟動專案報錯:Command line is too long. Shorten command line for className or also for JUnit defaultconfiguration. 解決方法: 在該專案資料夾.idea/worksp

typedef重複定義 和 error: ‘long long longis too long for GCC

今天發現一個很有意思的編譯問題,然後在Stack Overflow上也有看到類似的。就是出現了 long long long 型別錯誤提示 錯誤提示如下: /home/yejy/algorithm_and_data_structure/main.cpp:50:17: error: ‘long long lon

oracle ORA 00936 missing expression 的幾情況和解決方法

ORA-00936: missing expression   Cause: A required part of a clause or expression has been omitted. For example, a SELECT statement may have been entered wi