Workaround for ORA-00997: illegal use of LONG datatype

前端 未结 2 700
猫巷女王i
猫巷女王i 2020-12-10 13:00

I want to save some data from a system table user_tab_cols, to a temp table so I can take a dump from it.

There are 100,000 rows in it , I have select from user_tab_

2条回答
  •  有刺的猬
    2020-12-10 13:57

    ORA-00997: illegal use of LONG datatype

    It is a restriction on usage of LONG data type. You cannot create an object type with a LONG attribute.

    SQL> CREATE TABLE t AS SELECT data_default FROM user_tab_cols;
    CREATE TABLE t AS SELECT data_default FROM user_tab_cols
                             *
    ERROR at line 1:
    ORA-00997: illegal use of LONG datatype
    
    
    SQL>
    

    Alternatively, you could use TO_LOB as a workaround. Which would convert it into CLOB data type.

    For example,

    SQL> CREATE TABLE t AS SELECT TO_LOB(data_default) data_default FROM user_tab_cols;
    
    Table created.
    
    SQL> desc t;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     DATA_DEFAULT                                       CLOB
    
    SQL>
    

    See more examples of workarounds here.

提交回复
热议问题