我渴望的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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 鍵盤insert操作怎麼取消?電腦鍵盤insert操作取消教程
- 即使瘋狂吃書,我仍渴望著《零》的新作
- 不同insert操作產生的undo的測試
- Oracle中的insert/insert all/insert firstOracle
- Seata-AT模式+TDDL:構建Insert操作的後映象在執行SELECT LAST_INSERT_ID()時報錯模式AST
- 渴望力量嗎?少年!流的原理
- insert all和insert first語句的用法
- 二分搜尋樹系列之[ 插入操作 (insert) ]
- 二分搜尋樹系列之「 插入操作 (insert) 」
- 少年 你渴望力量嗎?
- 我的常用tmux操作命令UX
- ES(Elastic Search)update操作設定無 docment時進行insertAST
- MyBatis的Insert操作自增主鍵的實現,Mysql協議與JDBC實現MyBatisMySql協議JDBC
- mysql insert的特殊用法MySql
- insert into select
- 少年,你渴望超程式設計的力量嗎?——symbol程式設計Symbol
- 怎樣提高insert的效能
- 我們需要注意的 immutable 操作
- 有一種渴望叫做等你出現
- SQL__INSERTSQL
- E - Insert or Erase
- insert images to a plot
- 【巨杉資料庫Sequoiadb】【諮詢】【資料操作】【索引】高併發 insert資料庫索引
- Sqlserver、oracle中Merge的使用方法,一個merge語句搞定多個Insert,Update,Delete操作SQLServerOracledelete
- [20181120]奇怪的insert語句.txt
- mysql insert into ... select的鎖問題MySql
- DYLD_INSERT_LIBRARIES的那些事
- 解析MySQL中INSERT INTO SELECT的使用MySql
- Go的位操作(&, |, ^, &^) 之我裂開了!Go
- leetcode–57–Insert IntervalLeetCode
- SQLite Insert 語句SQLite
- ArrayList宣告,Add(), Insert();
- # 寫給記性差的我的docker基本操作Docker
- 盈利背後,美團渴望第二曲線
- c/c++ 標準順序容器 之 push_back,push_front,insert,emplace 操作C++
- LeetCode之Insert Interval(Kotlin)LeetCodeKotlin
- Leetcode 35 Search Insert PositionLeetCode
- SQLite 之 INSERT OR REPLACE使用SQLite
- [20180907]insert+with+select.txt