必须会的SQL语句(三) 数据插入
1.规范一些使用插入语句的小规范
1)中文字符串前 最好 加一个N
2)列名用中括号 扩起来 像这样 [列名]
2.常规写法
Insert into tableName
( [column1] , [column2] )
values
(N'中文','11ds')
3.多行一条语句插入多行
insert into 表名 ([列1],[列2])
select '值1','值2' union all --这里呢,union 和 union all的 区别
--主要是对于重复值得处理,union 会过滤掉重复行,而union all会全插进去
select '值3','值4' union
select '值5','值6'
4.复制到新表 将原有表中的数据复制到一个不存在的新表中
select * into newtable from oldtable
--仅复制表结构如何做呢?
select * into newtable from oldtable where 1<>1
select 0 * into newtable from oldtable
5.插入其他表的数据 向一个已有表中,复制其他表的数据
insert into tablename(column,column2)
select column,column2 from oldtable
6.强行写入 强行写入标识字段。
--对于已经设置自动增长的列,默认情况我们无法对其输入值。
--可以用一下语句去强行写入。
--1)开启添加,(解除添加的限制)
Set indentity_insert tablename On
--2)可以手动插入id了
insert into 表明 (id,name) values ('1002','大二')
--3)关闭手动插入
Set indentity_insert tablename off
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程