语句、聚合函数、数学函数、字符串函数、时间日期函数

 
--添加列
alter table shuiguo add price decimal(18,2)
--删除列
alter table shuiguo drop column price

--更改数据库的名称,逗号前面是之前的,逗号后是要改成的名字 sp_renamedb student,xuesheng

更改数据库的名称

表中有数据的情况下再添加列、删除列

语句示例

复制代码
--查询所有数据
select * from xuesheng
--查询开头是王的所有数据
select * from xuesheng where name like '王%'
--查询语文最高分
select top 1 * from xuesheng order by yuwen desc
--查询叫王三的语文、数学分数
select yuwen,shuxue from xuesheng where name='王三'
--查询语文分数在50到70学生的所有数据
select * from xuesheng where yuwen between 50 and 70
复制代码

语句示例:

模糊查询的语句:

排序语句

聚合函数:sum、avg、max、min、count

使用方法示例:

group by 分组的使用方法

分组的练习:

数学函数:ABS、ceiling、floor、power、round、sqrt、square

数据库的简单查询练习:

字符串函数:

时间日期函数:

数据转换、函数转换

原文地址:https://www.cnblogs.com/baimangguo/p/6072451.html