数据类型:
bit //相当于bool 只有两种选择1/0
char[num] //字符串
nvarchar //可能含有中文
varchar //不会用空格代替 var(variable 可变的)
CREATE TABLE YU(NAME CHAR(5) NOT NULL,AGE INT NOT NULL);
DROP TABLE YU;
INSERT INTO People1(Number,NAME,AGE) values (2,'yu',20);
INSERT INTO People1(Number,NAME,AGE) values (newid()/*类型不是INT*/,'yu',20);
delete from ... where age>10;
select destinct ... \\指删除完全重复的数据
union (all) //连接两个select 数据类型得相容,默认合并重复行,加快执行速度一般都加ALL
select *(选中所有)/名称/[可拖选](row) from ...
order by ... desac //desc = descending order(逆序排列);asc = ascending order
order by ... desac, ... 多种组合排序(默认为正序)
order by num;
isnull(rowname,'')as rowname //在select中
'string'+date+'string'as rowname //可重新描述某段
where rowname /*判断条件得出选中row*/ exp:money>1000 //字符加数字型用字符串判断
and //表示同时判断多个条件 且&&
between '...' and '...' //从...到... '2005-8-15'or'15/8/2005'
or
where color ='white' or color='red' //满足其中一个条件 或||
where name like'%rowname%' //模糊搜索
where name like'_owname%'
where color in ('red','white','black')
where class not in('H') //与上相反
where size is null/is not null
select count(...)
select distinct(...) //select count(distinct(...))
select Avg()/Min/Max/Sum () as ...name //在使用时用 group by ...
having Max(TotalDue)>1500 //对聚合函数使用的筛选
round(date,num) //num=1表示小数后保留一位,num=0表示取整
ABS() //绝对值
ceiling //天花板 取整
len() //计算字符串的长度
sbstring(string ,startNum,len)
bit //相当于bool 只有两种选择1/0
char[num] //字符串
nvarchar //可能含有中文
varchar //不会用空格代替 var(variable 可变的)
CREATE TABLE YU(NAME CHAR(5) NOT NULL,AGE INT NOT NULL);
DROP TABLE YU;
INSERT INTO People1(Number,NAME,AGE) values (2,'yu',20);
INSERT INTO People1(Number,NAME,AGE) values (newid()/*类型不是INT*/,'yu',20);
delete from ... where age>10;
select destinct ... \\指删除完全重复的数据
union (all) //连接两个select 数据类型得相容,默认合并重复行,加快执行速度一般都加ALL
select *(选中所有)/名称/[可拖选](row) from ...
order by ... desac //desc = descending order(逆序排列);asc = ascending order
order by ... desac, ... 多种组合排序(默认为正序)
order by num;
isnull(rowname,'')as rowname //在select中
'string'+date+'string'as rowname //可重新描述某段
where rowname /*判断条件得出选中row*/ exp:money>1000 //字符加数字型用字符串判断
and //表示同时判断多个条件 且&&
between '...' and '...' //从...到... '2005-8-15'or'15/8/2005'
or
where color ='white' or color='red' //满足其中一个条件 或||
where name like'%rowname%' //模糊搜索
where name like'_owname%'
where color in ('red','white','black')
where class not in('H') //与上相反
where size is null/is not null
select count(...)
select distinct(...) //select count(distinct(...))
select Avg()/Min/Max/Sum () as ...name //在使用时用 group by ...
having Max(TotalDue)>1500 //对聚合函数使用的筛选
round(date,num) //num=1表示小数后保留一位,num=0表示取整
ABS() //绝对值
ceiling //天花板 取整
len() //计算字符串的长度
sbstring(string ,startNum,len)