![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
sql sever
秋也呀
这个作者很懒,什么都没留下…
展开
-
Sql server数据库——对表操作(7)
创建表(primary key:主键,identity(1,1):自增,初始值1,递增1,check():检查约束)create table users(username varchar(20)primary key,pwd varchar(10),name varchar(20),gender varchar(2),birth date,balance decimal(8,2))删除表drop table bikes创建数据库create database table2原创 2021-06-06 20:48:07 · 88 阅读 · 0 评论 -
Sql server数据库——连接查询(6)
连接查询1.内连接查询(join... on...获取两张表的数据)(1)获得全部数据select * from table_1 t join Products p on t.id=p.ProductID(2)获得部分数据select * from table_1 t join Products p on t.id=p.ProductID where t.name='小美'(3)多表连接查询三表查询select * from table_1 t join products p on t.id原创 2021-06-05 10:49:08 · 251 阅读 · 0 评论 -
Sql server数据库知识总结(5)
聚合函数和分组查询1.SUM聚合函数,MAX聚合函数,MIN聚合函数(1)SUM聚合函数(计算单列或多列的总和)select sum(id) from table_1select sum(id) from table_1 where name='小美'(2)max:最大值 min:最小值select max(id),min(id) from table_1select max(id),min(id) from table_1 where name='小明'2.avg函数和count(1)原创 2021-06-04 17:47:07 · 46 阅读 · 0 评论 -
Sql server数据库知识总结(4)
函数的使用1.字符串函数(1)replace(替换字符串)函数select REPLACE ('mimi','i','a') (2)reverse函数(按相反顺序返回字符表达式)select reverse('name')(3)str函数(返回数字数据换来的字符数据)select str('123.45') str,str ('123.45',5,1) str,str('123.45',3,1) str,str('123.45',3,1) str,str('123.45',2,2)原创 2021-06-03 22:06:15 · 51 阅读 · 0 评论 -
Sql server数据库知识总结(3)
select定制查询一.SQL server运算符(除法不能为0)(创建表:create table tmp1(num int))1算术运算符(+、-、*、/、%)select id,id+1 加,id-1 减,id*2 乘,id/1 除,id%2 取余 from Table_12比较运算符(=、<>或!=、>=、<=、>、<、is null、is not null)3逻辑运算符(all、and、any、between、exists、in、like、not、o原创 2021-06-02 11:43:31 · 75 阅读 · 0 评论 -
Sql server数据库知识总结(2)
三.删除表记录1.删除表中所有记录(delete from 表名)delete from Table_12.按指定条件删除条件(delete from 表名 where 列名='')delete from Table_1 where id=1四.select选择列表1.选择列表(select * from 表名)所有列(*代替全部列名)select * from Table_1部分列(select 列名 from 表名)select name from Table_1sele原创 2021-06-01 14:03:04 · 218 阅读 · 0 评论 -
Sql server数据库知识总结(1)
一、新增数据表的数据1.添加一行(insert into 表名(列名)values(对应列名添加的数据,对应列名添加的数据,))insert into Table_1(name,ID,birthday) values ('张小三',1,'1989-8-2')insert into Table_1 values ('小美',1) 字段都添加数据时,字段名可省略insert Table_1(name,ID) values ('',2)2.添加多行(insert into 表名(列名)select 对原创 2021-05-31 21:37:05 · 112 阅读 · 0 评论