fkjj.net
当前位置:首页 >> orAClE将查询到的数据插入到一个新表的存储过程 >>

orAClE将查询到的数据插入到一个新表的存储过程

很简单,代码如下 create or replace procedure test is begin --两个表字段一样 insert into 表名1 select * from 表名2; --字段不一样 insert into 表名1(字段1,字段2,字段3) select 字段1,字段2,字段3 from 表名2; COMMIT; end

DECLARE begin INSERT INTO A表(ID,NAME,TIME) SELECT ID,NAME,SYSDATE FROM B表; COMMIT; end; 修改一下自己的表明和字段就可以了

不用存储过程,直接INSERT就行 insert into D (select * from A where mz not in(select mz from B) and jg not in(select jg from C)); 你要存储过程的话再加个壳 create or replace procedure XXX IS begin insert into D (select * from A wh...

很简单,代码如下 create or replace procedure test is begin --两个表字段一样 insert into 表名1 select * from 表名2; --字段不一样 insert into 表名1(字段1,字段2,字段3) select 字段1,字段2,字段3 from 表名2; COMMIT; end

看你的这两个用户是不是在同一个数据库中,如果不是同一个数据库,可以建立一个DBLINK来连接;如果是在同意个库内可以这样写: insert into A(column1,column2,column3) select bbb.B.columns1,bbb.B.columns2,bbb.B.columns3 from bbb.B where b...

实际上存储过程向表中插入数据和sql执行的区别是不大的,只不过是存储过程是用loop等循环插入,之后顺序执行sql语句,不用命令行执行。 CREATE OR REPLACE PROCEDURE insert_data_4_pressure_3 is --Result1 VARCHAR2(50); VAR_num number;begin...

给你一个sql语句的例子吧: update B set b.name = (select A.name from A where A.id = B.aid)where exists(select 1 from A where A.id = B.aid)

简要代码如下,可根据实际情况适当修改: create or replace procedure pro_name asbegin insert into b select * from a t where (sysdate - t.时间字段)>30; delete from a where (sysdate - t.时间字段)>30; end pro_name;

先把表创建起来,然后用insert语句插入。 create or replace procedure P_Insert(v_date in varchar2,v_cp varchar2) is begin INSERT INTO ora201301 SELECT * FROM bh WHERE 字段名1 BETWEEN v_date||'/01' AND v_date||'/31' AND 字段名2=v_c...

PROCEDURE P1 IS BEGIN DELETE FROM A1; DELETE FROM B1; DELETE FROM C1; INSERT INTO A1 SELECT * FROM A; INSERT INTO B1 SELECT * FROM B; INSERT INTO C1 SELECT * FROM C; INSERT INTO A2 SELECT * FROM A; INSERT INTO B2 SELECT * FROM ...

网站首页 | 网站地图
All rights reserved Powered by www.fkjj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com