SQL
文章平均质量分 73
sss...sql
youdabi
学习中。。。 记录笔记 (^-^)V
展开
-
SQL 六大约束及distinct、top、percent、isnull
六大约束1.主键约束(唯一约束 + 非空约束) primary key2.外键约束 foreign key(字段) references 主表名(字段)3.唯一约束(允许一行数据为空) unique4.默认值约束 default5.检查约束 check6.非空约束 not null--新建 学生表create table student( stuid int not null, stuname varchar(100) not null, stuage int not.原创 2022-05-09 00:36:33 · 348 阅读 · 0 评论 -
高级子查询 及视图
/** 高级子查询 **/--查询年龄比李昊大的学生信息--[1] 先查询到李昊的年龄 =》作为 约束条件select sage from Student where sname = '李昊'--[2] 然后查询select * from Student where sage<( select sage from Student where sname = '李昊')--查询大于平均年龄的学生信息--[1] 先查询到平均年龄select avg(sage) from ...原创 2022-05-05 19:11:58 · 42 阅读 · 0 评论 -
数据库之 高级查询
1.统计函数 (聚合函数)--只有一个结果count 总数,max 最大, min 最小,avg 平均,sum 求和[1] 求 数据总条数select count(*) from Student;[2] 求 年龄最大select max(age) from Student;[3] 求 年龄最小select min(age) from Student;[4] 求 平均年龄select avg(age) from Student;[5] 求 年龄总和select sum(age) fr原创 2022-05-04 23:49:52 · 356 阅读 · 0 评论 -
SQL数据库(上)
大纲1、安装数据库(2005/2008/2012/2014)2、启动数据库服务3、进入软件(sa)4、认识几个数据库master 系统数据库model 模型数据库tempdb 临时数据库msdb 警报日志信息5、创建数据库(.mdf数据文件 .ldf日志文件)包括了解一些属性create database stu02206、删除数据库 drop database stu02207、附加数据库 脱机 联机数据类型:intfloatvarchar(长度)char(长度原创 2022-05-03 21:54:33 · 463 阅读 · 0 评论