SYBASE的select into与insert into使用和区别
来源:互联网 发布:误删数据库怎么恢复 编辑:程序博客网 时间:2024/05/16 05:00
对于表的部分或全部字段的复制,Sybase数据库提供了两种方式:select into和insert into。
select into:
语法:select value1, value2, value3 ...into table2 from table1.
注意:
①被插入的表table2必须是不存在的,在执行语句的时候创建table2表。如果已经存在,执行时会报错。
②插入的value1,value2,value3等不能是常量。
(2016/09/05日修正:虽然不能直接写一个常量,但是插入常量也是可以的,只需要给这个插入的常量命名作为列名。请参考下面的例子③和例子④---罪过啊,现在才知道,不知道有没有坑看过这篇博客的朋友,罪过。。。)
例子:
①select id, name, age into tempdb..testtable1 from student (复制部分字段)
②select * into tempdb..testtable2 from student (复制所有字段)
③select '10:00' hour, 'name' name, 28 age into #temp_table_one (为每一个插入的常量命名作为列名,就可以插入常量了)
④select *, 2 into #temp_table_two from #temp_table_one (如果只插入常量不命名,则会报错,报错信息如下所示)
插入常量时报错:
------------------------ Execute ------------------------
SELECT INTO failed because column 4 in table '#temp_table_two00005230001896877' has a null column name. Null column names are not allowed.
----------------- Done ( 1 errors ) ------------------
insert into:
语法:Insert into Table2(value1,value2,...) select value1,value2,... from Table1
注意:
①table2表必须已经存在。
②因为table2表已经存在,所以可以向其中插入常量。
例子:
①insert into tempdb..testtable4(id, name,age) select id, name, age from student
②insert into tempdb..testtable4 select * from student
③insert into tempdb..testtable4 select id, name, age from student
④insert into tempdb.. testtable4(id, name, age) select id, name, 27 from student (插入常量)
- SYBASE的select into与insert into使用和区别
- insert into ... select 和 select ... into的使用和区别
- INSERT INTO SELECT 和 SELECT INTO 用法与区别
- select into 和 insert into select区别
- SELECT INTO 和 INSERT INTO SELECT 区别
- insert into select与select into的区别
- select into和insert into select的区别
- SELECT INTO和INSERT INTO SELECT的区别
- select into 和 insert into select的区别
- Oracle中insert into select和select into的区别
- Oracle中insert into select和select into的区别
- SELECT INTO和INSERT INTO SELECT的区别
- INSERT INTO SELECT 和 SELECT INTO 语句的区别
- select into与insert into区别
- select into from 和 insert into select 的区别和使用
- insert into 和select into 插入记录的区别
- select into from 和 insert into from 的区别
- insert into from和select from into的区别
- 设计模式--观察者模式
- centos 7 忘记root密码修改过程
- 编程之美2.17之数组循环移位
- Codeforces Round #316 (Div. 2)
- 随笔-Xcode6新框架的屏幕适配,屏幕上下有黑条,iphone6上不能全屏,只能在左上角显示。
- SYBASE的select into与insert into使用和区别
- jsp页面foreach循环,表单提交,批量处理数据,
- 如何让tomcat在同一个DOS窗口启动
- Java注解
- 两层查询词扩展描述的简单排序
- VS2010,C语言编程调用函数sqrt
- git学习笔记
- Jquery的运用
- Scope Is the Enemy of Success