欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

sqlserver的增删改查

程序员文章站 2022-04-01 11:17:18
...

select * from shuiguo 查询表 select * from shuiguo where jiage between 5 and 7 ( between 表示大于等于 5 且小于等于 7 的范围) select distinct name from shuiguo -- 去除重复,只针对一列 select * from shuiguo where name = ' 苹果 ' and chandi

sqlserver的增删改查

select*from shuiguo 查询表

select * from shuiguo where jiage between 5 and 7between表示大于等于5且小于等于7的范围)

select distinct name from shuiguo--去除重复,只针对一列

select * from shuiguo where name='苹果' and chandi='海南'

select * from shuiguo where name in('苹果','香蕉')--name只包含苹果,香蕉的

select * from shuiguo where name not in('苹果','香蕉')--name中除了苹果,香蕉的

select * from shuiguo where name like '%%'--模糊查询,%叫通配符(%在前面表示前面有任何字符,%在后面表示后面有任何字符)

select * from shuiguo where name like '_'--下划线表示任意一个字符

select * from shuiguo order by jiage--升序排列

select * from shuiguo order by jiage desc --降序排列

select top 2* from shuiguo order by jiage--按升序排列,只取前两行(top 2

select top 1 * from shuiguo where name='苹果' order by jiage desc--按照条件查询后排序,查名字叫苹果的谁的价格高,只选第一个

delete from shuiguo where chandi='烟台' --删除水果表中产地是烟台的数据

alter table shuiguo add dianhua int --添加列名电话

update shuiguo set dianhua= 2255557 where code=2 --定义第几行的电话是多少

修改表加入新列   alter table abc add dianhua int

修改表删除一列   alter table abc drop column dianhua