create database mmm create table xxx ( code int primary key identity(1,1), name varchar(50) not null, sex varchar(50) not null, age int not null, hight decimal(18,2) not null, wight int not null, ) go insert into xxx values(‘佐助‘,‘男‘,20,175,100); insert into xxx values(‘鸣人‘,‘男‘,21,177,110); insert into xxx values(‘小樱‘,‘女‘,19,165,80); insert into xxx values(‘宁次‘,‘男‘,22,179,200); insert into xxx values(‘迪达拉‘,‘男‘,23,180,130); select *from xxx update xxx set name=‘我爱罗‘ where name=‘鸣人‘--吧鸣人换成我爱罗 delete from xxx where code=4--删除掉第四行 select*from xxx where name like ‘小%‘--找寻名字表里面有小的 select top 3*from xxx--只显示前三行 select top 2 code from xxx where age>19--显示表里面年龄大于19岁的两行 select *from xxx order by age--按照年龄开始排序 select distinct name from xxx--只显示名字 select *from xxx order by age,wight desc--按照年龄体重排序 select wight from xxx group by wight --按照体重排序 select age from xxx group by age --按照年龄排序 select name from xxx group by name --按照名字排序 select *from xxx where age-3<20--找寻年龄减3小于20岁的 select *from xxx where age in(19,20)--寻表里面年龄是19和20岁的 select *from xxx where name in(‘佐助‘)
原文:http://www.cnblogs.com/w-wz/p/4441790.html