第一种:
通过使用Oracle语句块
declare
cursor cur_test is select widgetid from t_widget;
begin
for c in cur_test loop
insert into t_tag (tagid,widgetid,userid,tagname,tagdate) values(s_tag_tagid.nextval,c.widgetid,'15895829126','nanjing',sysdate);
end loop;
commit;
end;
第二中:
使用纯SQL语句实现
insert into t_tag (tagid,widgetid,userid,tagname,tagdate) select s_tag_tagid.nextval,widgetid,'15895829126','nanjing',sysdate from t_widget
Oracle 从一个表查询出数据,插入另一张表
数据库 2010-12-16 14:36:43 阅读203 评论0 字号:大 中 小 订阅
例子一
insert into pm_per_res_page_ele
(RES_ID,ELE_TYPE_CODE,ELE_CODE,REMARKS)
select
per_res_page_ele_id.nextval as RES_ID,
'Menu.Left.Tree' as ELE_TYPE_CODE,
menu.menu_id as ELE_CODE,
menu.menu_name as REMARKS
from SYS_MENU menu
例子二
insert into BACKUP_SYS_MENU t
select
menu.*,sysdate,BACKUP_SYS_MENU_ID.Nextval
from SYS_MENU menu
通过使用Oracle语句块
declare
cursor cur_test is select widgetid from t_widget;
begin
for c in cur_test loop
insert into t_tag (tagid,widgetid,userid,tagname,tagdate) values(s_tag_tagid.nextval,c.widgetid,'15895829126','nanjing',sysdate);
end loop;
commit;
end;
第二中:
使用纯SQL语句实现
insert into t_tag (tagid,widgetid,userid,tagname,tagdate) select s_tag_tagid.nextval,widgetid,'15895829126','nanjing',sysdate from t_widget
Oracle 从一个表查询出数据,插入另一张表
数据库 2010-12-16 14:36:43 阅读203 评论0 字号:大 中 小 订阅
例子一
insert into pm_per_res_page_ele
(RES_ID,ELE_TYPE_CODE,ELE_CODE,REMARKS)
select
per_res_page_ele_id.nextval as RES_ID,
'Menu.Left.Tree' as ELE_TYPE_CODE,
menu.menu_id as ELE_CODE,
menu.menu_name as REMARKS
from SYS_MENU menu
例子二
insert into BACKUP_SYS_MENU t
select
menu.*,sysdate,BACKUP_SYS_MENU_ID.Nextval
from SYS_MENU menu