insert into 和select into(select into from和insert into select都是用来复制表,两者有什么区别)

本文目录
select into from和insert into select都是用来复制表,两者有什么区别
select into from 和 insert into select都是用来复制表,两者的主要区别为: select into from 要求目标表不存在,因为在插入时会自动创建。insert into select from 要求目标表存在。
备份表数据: create table emp as select * from scott.emp
还原表数据:insert into emp select * from scott.emp
复制表结构及其数据:
create table table_name_new as select * from table_name_old
只复制表结构:
create table table_name_new as select * from table_name_old where 1=2;
或者:
create table table_name_new like table_name_old
只复制表数据:
如果两个表结构一样:
insert into table_name_new select * from table_name_old
如果两个表结构不一样:
insert into table_name_new(column1,column2...) select column1,column2...
from table_name_old pasting
Oracle中insert into select和select into的区别
Oracle中insert into select和select into的区别
oracle中insert into select用语将数据插入到表中。
select into 一般用于存储过程或函数等,将某个查询结果放入变量中。
举例:
1、insert into select
1
2
insert into a select * from b;
commit;
2、select into
create or replace procedure p_test
as
v_begintime varchar2(20);
v_endtime varchar2(20);
v_str varchar2(10);
begin
v_begintime:=to_char(sysdate,’yyyy-mm-dd hh34:mi:ss’);
select ’badkano’ into v_str from dual;--其中这句是将某个值放入v_str变量中
v_endtime:=to_char(sysdate,’yyyy-mm-dd hh34:mi:ss’);
dbms_output.put_line(’开始时间为:’||v_begintime);
dbms_output.put_line(’结束时间为:’||v_endtime);
end;

更多文章:
html按钮的类型(html编程里的界面设置按钮类型,如下图的描述,该如何编写点击上排的按钮,在下面显示内容,不换网页)
2026年2月22日 20:45
为什么爬虫都用python(为什么写爬虫都喜欢用python)
2025年8月4日 14:00
anticipate的同义词(怎样记住单词anticipate)
2026年3月15日 20:30
vlookup函数的功能和用法(vlookup函数的主要功能是什么)
2025年11月6日 22:15
需要用到volatile的场合(java volatile在什么场景下适用)
2026年6月3日 11:15
order by原理(oracle中在in子查询语句中order by排序能否用)
2025年7月25日 15:00
jav hdxrw(jAVHDc0M丁uB8 m.tub8为什么找不到一答案.me)
2026年5月16日 08:45
extension strategy(jdbc链接oracle网络适配器问题)
2025年11月5日 14:45
织梦内容管理系统打开要什么(织梦内容管理系统打开时怎么那么慢)
2026年2月23日 22:15
ueditor上传图片写入数据库(ueditor富文本编辑器上传图片怎么配置)
2025年12月7日 11:00
使用md5后能不能破解(用MD5加密后的字段有反解密的方法吗)
2025年10月15日 18:00











