我渴望的insert操作!
SQL> desc tt7
名稱 是否為空? 型別
----------------------------------------- -------- ----------------------------
ID NUMBER(38)
NAME VARCHAR2(10)
SQL> select * from tt7;
ID NAME
---------- ----------
1 a
2 a
1 a
a
a
3 A
4 A
5 B
6 b
已選擇9行。
SQL> create table tt8 as select * from tt7 where 1=2;
表已建立。
SQL> edit
已寫入 file afiedt.buf
1 declare
2 begin
3 for x in (select * from tt7) loop
--一直都以為oracle不支援把"行"變數直接和insert操作關聯起來使用,這裡"行"變數這個名字是我給起的,不知道是否準確,只要大家能理解就ok.
4 insert into tt8 values x;
5 end loop;
6* end;
SQL> /
PL/SQL 過程已成功完成。
SQL> select * from tt8;
ID NAME
---------- ----------
1 a
2 a
1 a
a
a
3 A
4 A
5 B
6 b
已選擇9行。
SQL>
SQL> edit
已寫入 file afiedt.buf
1* truncate table tt8
SQL> declare
2 cursor c1 is select * from tt7;
3 v_tt tt7%rowtype;
4 begin
5 open c1;
6 fetch c1 into v_tt;
7 while c1%found loop
8 insert into tt8 values v_tt;
9 fetch c1 into v_tt;
10 end loop;
11 close c1;
12 commit;
13 end;
14 /
PL/SQL 過程已成功完成。
SQL> declare
2 cursor c1 is select * from tt7;
3 type v_tt_type is record(
4 id tt7.id%type,
5 name tt7.name%type
6 );
7 v_tt v_tt_type ;
8 begin
9 open c1;
10 fetch c1 into v_tt;
11 while c1%found loop
12 insert into tt8 values v_tt;
13 fetch c1 into v_tt;
14 end loop;
15 close c1;
16 commit;
17 end;
18 /
PL/SQL 過程已成功完成。
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-1015318/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- c#中的insert操作C#
- Oracle使用者——我渴望開源資料庫(轉)Oracle資料庫
- 鍵盤insert操作怎麼取消?電腦鍵盤insert操作取消教程
- 渴望力量嗎?少年!流的原理
- MySQL insert的內部操作流程介紹MySql
- 不同insert操作產生的undo的測試
- 【SQL】 Multi table insert 多表插入操作SQL
- MySQL之資料的insert-delete-update操作MySqldelete
- 併發insert操作導致的dead lock
- mysql操作命令梳理(2)-alter(update、insert)MySql
- insert操作放在undo中的rowid怎麼來的!
- Oracle中的insert/insert all/insert firstOracle
- MyBatis insert操作插入,返回主鍵from官方MyBatis
- 自由職業者渴望得到的10個工具
- 關於insert操作造成索引葉節點分裂的驗證索引
- LINQ to SQL語句之Insert/Update/Delete操作SQLdelete
- Oracle資料庫中Insert、Update、Delete操作速度Oracle資料庫delete
- 少年,你渴望超程式設計的力量嗎?——symbol程式設計Symbol
- Oracle 的 INSERT ALL和INSERT FIRSTOracle
- Seata-AT模式+TDDL:構建Insert操作的後映象在執行SELECT LAST_INSERT_ID()時報錯模式AST
- 二分搜尋樹系列之[ 插入操作 (insert) ]
- 二分搜尋樹系列之「 插入操作 (insert) 」
- insert /*+ append */ into 與insert into 的區別APP
- INSERT ALL 和INSERT FIRST 的區別
- mysqPoint型別查詢和插入操作:insert和select型別
- 我們需要注意的 immutable 操作
- ES(Elastic Search)update操作設定無 docment時進行insertAST
- MyBatis的Insert操作自增主鍵的實現,Mysql協議與JDBC實現MyBatisMySql協議JDBC
- Go的位操作(&, |, ^, &^) 之我裂開了!Go
- shell解決我繁瑣的sqlldr操作SQL
- mysql insert的特殊用法MySql
- insert WITH CHECK OPTION的用法
- 查詢v$logmnr_contents表沒有找到insert,update 操作的記錄
- # 寫給記性差的我的docker基本操作Docker
- 渲染大量資料我是這樣操作的
- Multitable Insert
- Merge into: Oracle中用一條SQL語句直接進行Insert/Update的操作(R1)OracleSQL
- java操作Excel(從我的CSDN搬過來的)薦JavaExcel