格式:insert into 表名(列1,列n)select 数据1,数据n unionselect 数据,数据n unionselect 数据1,数据n;
复制数据到旧表
格式:insert into 要插入的表名称(列1,列n) select 源列1,源列n from 数据源表名称;
复制到新表
格式:select 原表名.列1,原表名.列n into 新表名 from 原表名;
删 delete
delete删除
格式:delete from 表名 where 条件
delete删除
格式:delete from 表名 where 条件
改 update
格式:update 表名 set 列名1=值1,列名n=值n where 条件
DQL 数据表的查询语言
查询基础
查询表中所有的列信息
格式:select * from 表名
查询表中指定列的信息
格式:select 列名1,列名n from 表名
格式:select 表名.列名1,表名.列名n from 表名
查询符合条件的信息
格式:select * from 表名 where 条件
查询一定量的数据
(按百分比查询)格式:select top 条目数 * from 表名
(按条目数查询)格式:select top 百分比 percent * from 表名
查询条件
查询为空的
格式:where 列名 is null
查询非空的
格式:where 列名 is not null
模糊查询
通配符
代表一个(_)
赖子(%)
字符集(内容a,内容b)
字符集取反(^内容c,内容d)
范围查找
between...and
格式:列名 between 最小值 and 最大值
... and ...
格式:列名>=最小值 and 列名<=最大值
聚合函数
求总和
sum
格式:sum(列名)
求总数
count
格式:count(列名)
求总数
count
格式:count(列名)