[20120910]建立包含long型別的表.txt
需要往一個表裡面append一些資料,而表內有long 欄位。處理還真麻煩,記錄一下。
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> create table t (id number,pic long);
Table created.
SQL> insert into t values (1,'aaaaaaaaaaaaaaaa');
1 row created.
SQL> create table t1 as select * from t;
create table t1 as select * from t
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
SQL> create table t1 (id number,pic long);
Table created.
SQL> insert into t1 select * from t;
insert into t1 select * from t
*
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
--看來含有LONG的欄位處理起來很麻煩。 當然方法很多,看了一些blog,發現最簡單的是使用sqlplus帶的copy命令,
--可以實現。記錄一下。俺以前經常用,現在差不多忘記了!!
--參考連結如下:
SQL> help copy
COPY
----
Copies data from a query to a table in the same or another
database. COPY supports CHAR, DATE, LONG, NUMBER and VARCHAR2.
COPY {FROM database | TO database | FROM database TO database}
{APPEND|CREATE|INSERT|REPLACE} destination_table
[(column, column, column, ...)] USING query
where database has the following syntax:
username[/password]@connect_identifier
SQL> copy from scott/xyzxyz@192.168.200.56/test.com to scott/xyzxyz@192.168.200.56/test.com append t1 using select * from t;
Array fetch/bind size is 200. (arraysize is 200)
Will commit when done. (copycommit is 0)
Maximum long size is 20000000. (long is 20000000)
1 rows selected from scott@192.168.200.56/test.com.
1 rows inserted into T1.
1 rows committed into T1 at scott@192.168.200.56/test.com.
SQL> set long 100
SQL> select * from t1;
ID PIC
---------- -----------------
1 aaaaaaaaaaaaaaaa
SQL> copy from scott/xyzxyz@192.168.200.56/test.com to scott/xyzxyz@192.168.200.56/test.com create t2 using select * from t;
Array fetch/bind size is 200. (arraysize is 200)
Will commit when done. (copycommit is 0)
Maximum long size is 100. (long is 100)
Table T2 created.
1 rows selected from scott@192.168.200.56/test.com.
1 rows inserted into T2.
1 rows committed into T2 at scott@192.168.200.56/test.com.
SQL> desc t2;
Name Null? Type
------ -------- ------------
ID NUMBER(38)
PIC LONG
SQL> select * from t2;
ID PIC
---------- ----------------
1 aaaaaaaaaaaaaaaa
--另外不要設定long引數太小,否則會被截斷!
SQL> set long 5
SQL> copy from scott/xyzxyz@192.168.200.56/test.com to scott/xyzxyz@192.168.200.56/test.com insert t2 using select * from t;
Array fetch/bind size is 200. (arraysize is 200)
Will commit when done. (copycommit is 0)
Maximum long size is 5. (long is 5)
1 rows selected from scott@192.168.200.56/test.com.
1 rows inserted into T2.
1 rows committed into T2 at scott@192.168.200.56/test.com.
SQL> set long 50
SQL> select * from t2;
ID PIC
---------- --------------------------------------------------
1 aaaaaaaaaaaaaaaa
1 aaaaa
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-743054/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20181014]12Cr2 impdp使用NETWORK_LINK支援LONG欄位型別.txt型別
- 測試Java中的long,int基本型別Java型別
- Spring Mvc Long型別精度丟失SpringMVC型別
- 讀取oracle long型別及判斷是否自動分割槽表Oracle型別
- c++ 基本資料型別(int、float、double、long、long long)最大值,最小是表示方法C++資料型別
- long資料型別跨平臺問題資料型別
- [20190612]NULL的資料型別.txtNull資料型別
- 建立多種型別的流型別
- 建立NFS型別的儲存NFS型別
- [20181108]with temp as 建立臨時表嗎.txt
- Java中建立泛型型別的例項Java泛型型別
- mysql指令1:增刪改庫,資料型別,建立表MySql資料型別
- [20231013]CLOB型別的編碼問題.txt型別
- springboot jap自定義原生sql 接收SELECT count(*) 的返回long型別結果Spring BootSQL型別
- longValue( )和Long.valueOf( )的區別
- Java中Switch支援String字串?為什麼不支援long型別?Java字串型別
- Long型別框架自動序列化成String失效問題排查型別框架
- 建立一種新的資料型別資料型別
- [20191219]oracle timestamp資料型別的儲存.txtOracle資料型別
- 表連線型別型別
- ORACLE物件型別表Oracle物件型別
- [20190531]lob型別pctversion 和 retention.txt型別
- MySQL 的索引型別及如何建立維護MySql索引型別
- [20181021]臨時表lob段建立在哪裡.txt
- 什麼是Python型別轉換?主要包含什麼?Python型別
- 常見的網路攻擊型別有哪些?主要包含什麼?型別
- php型別比較表PHP型別
- UnrealEngine建立自定義資產型別Unreal型別
- [20190630]如何確定直方圖型別.txt直方圖型別
- [20241009]oracle timestamp with time zone資料型別的儲存.txtOracle資料型別
- [20191001]關於oracle number型別的一些疑惑.txtOracle型別
- 建立包含N個空物件的陣列物件陣列
- java: 不相容的型別: java.lang.Long無法轉換為java.lang.StringJava型別
- long long的加法溢位情況
- 用強資料型別保護你的表單資料-基於antd表單的型別約束資料型別
- python資料型別-列表建立和操作Python資料型別
- [20190930]oracle raw型別轉化number指令碼.txtOracle型別指令碼
- 2.5.9.1 指定預設表空間的型別型別
- 建立一個MySQL資料庫中的datetime型別MySql資料庫型別