【问题标题】:ORA-12899 Error Too large String for Same column but success different tablesORA-12899错误相同列的字符串太大但不同的表成功
【发布时间】:2020-05-09 15:27:28
【问题描述】:

我正在将字符串更新为长度为 35 的列到两个表中

第一个表更新成功,但第二个表给出 ORA 错误 ORA-12899 错误太大字符串

select length('Andres Peñalver D1 Palmar Sani salt') bytes from dual;

     BYTES
----------
        35

select lengthb('Andres Peñalver D1 Palmar Sani salt') bytes from dual;

     BYTES
----------
        36

两个表 colm1 字段都声明为 VARCHAR(35),第一个表更新失败,第二个成功。

update t
set colm1='Andres Peñalver D1 Palmar Sani Salt'
where value1='123456';

update t2
set colm1='Andres Peñalver D1 Palmar Sani Salt'
where value1='123456';

ORA-12899

select value from nls_database_parameters where parameter='NLS_CHARACTERSET';

VALUE                                                           
----------------------------------------------------------------
AL32UTF8

让我知道为什么这些具有相同列类型的表会出现这种行为

【问题讨论】:

    标签: oracle ora-12899


    【解决方案1】:

    检查 all_tab_columns 中两个表的实际列大小。 35 Char 是 3 乘以 35 字节,如果一个表的列是在 char 中定义的,而另一个是在字节中定义的(在 ddl 期间),则大小是不同的。 像 A-Z a-z 这样的普通字符需要 1 个字节来存储,但特定语言的字符需要 3 个字节来存储。

    【讨论】:

    • 有意义的是一张表是 35 字节和其他 35 个字符
    【解决方案2】:

    错误消息文档中描述的完整错误消息 应该会给你答案:

    $ oerr ora 12899
    12899, 00000, "value too large for column %s (actual: %s, maximum: %s)"
    // *Cause: An attempt was made to insert or update a column with a value
    //         which is too wide for the width of the destination column.
    //         The name of the column is given, along with the actual width
    //         of the value, and the maximum allowed width of the column.
    //         Note that widths are reported in characters if character length
    //         semantics are in effect for the column, otherwise widths are
    //         reported in bytes.
    // *Action: Examine the SQL statement for correctness.  Check source
    //          and destination column data types.
    //          Either make the destination column wider, or use a subset
    //          of the source column (i.e. use substring).
    

    这很可能与character length semantics有关。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2015-02-19
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 2016-09-15
      • 1970-01-01
      相关资源
      最近更新 更多