当前位置: 首页 > news >正文

营销网站建设哪里好薇腾讯企业qq

营销网站建设哪里好薇,腾讯企业qq,个人开个装修小公司,潮汕网站建设antnw一,数据库约束 1.1 约束对象 not null - 该列不能为空unique - 保证该列的每一行都不一样default - 规定没有给列赋值时的默认值(自定义)primary key - not null 和 unique 的结合,会给该列添加一个索引&#xff0…

一,数据库约束

1.1 约束对象

  • not  null  -  该列不能为空
  • unique  -  保证该列的每一行都不一样
  • default  -  规定没有给列赋值时的默认值(自定义)
  • primary  key  -  not  null  和  unique  的结合,会给该列添加一个索引,提高查询速度
  • foreign  key  -  保证一个表中的数据匹配另一个表的数据
  • check  -  保证列中的值符合指定的条件,对于MySQL数据库,堆check字句进行分析,但忽略check子句

1.2 null 约束

创建表时,指定某列不为空。 

1.3 unique 

保证该列的每一个值都是唯一的,即该列没有重复值。 

1.4 default

如果该列没有被赋值,那么就会赋值为 default 后面的值:

 1.5  primary   key - 主键约束

主键同时具有 not null 与 unique 的特点,还可以搭配 自增长auto_increment 来使用(插入字段不赋值时,使用最大值+1,有点类似于JAVA中的枚举)。

 注:auto_increment 只能作用于整数类型!!!!

1.6 foreign key - 外键约束

外键用于关联其他表的主键或唯一键,语法:

foreign  key  (字段名)  references  主表(列名)

表示 class_id 与 id 联系起来,添加的class_id必须存在于id中,否则添加失败,即 子表必须依赖父表 。并且不能单独删除 class 表,想删除class表必须先删除student表,因为要是先删除class表,那么student表中 class_id列就没有参考了。

1.7 check 约束

MySQL使用时不报错,但忽略该约束

二,表的设计 

  •  一对一  :类似于人与身份证号,一个人只能有一个身份证号
  • 一对多   :类似于班级与学生,一个班级可以有很多的学生
  • 多对多   :类似于学科与学生与老师

 三,新增

insert  into  表名 【列名....】 select .... 

四,查询 

4.1 聚合查询

4.1.1 聚合函数

函数说明
count (【distinct】列名)返回查询到的数据的  数量
sum (【distinct】列名)返回查询到的数据的  总和
avg (【distinct】列名)返回查询到的数据的  平均值
max (【distinct】列名)返回查询到的数据的  最大值
min (【distinct】列名)返回查询到的数据的  最小值
  • count

 注:count(*) 与 count(0) 效果一样!!!

  • sum

  • avg

  • max

  • min

注:当遇到null时,聚合函数不会理会,即不会让null进行运算!!! 

4.1.2 group  by 字句

分组查询:将表中的数据按照列进行分组,必须和聚合函数一起使用,例如:将一个班的学生分成一组。

select  column1,sum(column2),...... from table  group  by  column3...

 4.1.3 having

group by 子句进行分组以后,需要对分组结果再进行条件过滤时,不能使用 where 语句,而需要用 having

 4.2 联合查询

实际开发中我们所要的数据往往来自不同的表中,所以需要多表联合查询,要了解联合查询,就要先了解笛卡尔积,简单来说就是将多个表排列组合形成一张新的表,然后再根据表之间的联系(比如之前讲的 primary key 与 foreign key 的联系)以及我们的需求筛选出我们要查找到内容。但是需要注意的是,这种操作一般能不用就不用,因为要查找的内容过于庞大,会导致服务器阻塞(当然在自己的库试试没事,毕竟没多少数据)

  • 内连接

两种写法:

select  column... from 表1  join  表2  on  条件1   and  条件2...;

select  column... from 表1 ,表2...  where  条件1   and  条件2...;

//可以使用别名

 

  • 外连接

select  column... from 表1  left/right join  表2  on  条件1   and  条件2...;

画个图看一看内连接与外连接的区别:

 

  • 自链接

顾名思义就是指同一张表连接自身进行查询

 

  • 子查询

简单来说就是 select 和 select 可以套用 

例如:

select  *  from  student  where  class_id = (select  class  from  student  where  id  in(1,2,3)); 

  • 合并查询

 在实际应用中,为了合并多个select的执行结果,可以使用集合操作符 union,union all。使用union 和 union all 时,前后查询的结果集中,字段需要一致.

例如:

select  *  from  stduent  where  age  <  20  union / union all  select  *  from student  where id < 10;

union 可以自动去重,union all 不去重。


文章转载自:
http://consignation.wghp.cn
http://interlining.wghp.cn
http://vulcanic.wghp.cn
http://refusal.wghp.cn
http://mafiology.wghp.cn
http://canular.wghp.cn
http://waspy.wghp.cn
http://igg.wghp.cn
http://nfwi.wghp.cn
http://pav.wghp.cn
http://subsidise.wghp.cn
http://streptococcic.wghp.cn
http://aircraft.wghp.cn
http://polonium.wghp.cn
http://monopolize.wghp.cn
http://tripartite.wghp.cn
http://assassin.wghp.cn
http://marl.wghp.cn
http://azide.wghp.cn
http://lych.wghp.cn
http://grossularite.wghp.cn
http://unfriendly.wghp.cn
http://pneumoconiosis.wghp.cn
http://undercliff.wghp.cn
http://blasphemous.wghp.cn
http://ecpc.wghp.cn
http://spelldown.wghp.cn
http://reeb.wghp.cn
http://apochromatic.wghp.cn
http://angelophany.wghp.cn
http://cytogamy.wghp.cn
http://lampblack.wghp.cn
http://mesonephros.wghp.cn
http://lacework.wghp.cn
http://percolate.wghp.cn
http://caseinogen.wghp.cn
http://scathing.wghp.cn
http://nonvanishing.wghp.cn
http://ciliolate.wghp.cn
http://tenpence.wghp.cn
http://sarawak.wghp.cn
http://pyrolysis.wghp.cn
http://hagberry.wghp.cn
http://bettina.wghp.cn
http://telecentre.wghp.cn
http://decimalise.wghp.cn
http://springe.wghp.cn
http://berbera.wghp.cn
http://substandard.wghp.cn
http://charkha.wghp.cn
http://pree.wghp.cn
http://brickbat.wghp.cn
http://spiny.wghp.cn
http://relegate.wghp.cn
http://ostracon.wghp.cn
http://uncustomed.wghp.cn
http://adversary.wghp.cn
http://klischograph.wghp.cn
http://cullis.wghp.cn
http://kawasaki.wghp.cn
http://buckjump.wghp.cn
http://kana.wghp.cn
http://unitary.wghp.cn
http://termagancy.wghp.cn
http://disposed.wghp.cn
http://pedestrianism.wghp.cn
http://zymogenic.wghp.cn
http://centime.wghp.cn
http://shiralee.wghp.cn
http://rumford.wghp.cn
http://perfusion.wghp.cn
http://crossarm.wghp.cn
http://lobeliaceous.wghp.cn
http://cipango.wghp.cn
http://sapphiric.wghp.cn
http://disaster.wghp.cn
http://nappe.wghp.cn
http://gall.wghp.cn
http://bhakti.wghp.cn
http://zugunruhe.wghp.cn
http://piled.wghp.cn
http://desultor.wghp.cn
http://myg.wghp.cn
http://tombouctou.wghp.cn
http://asla.wghp.cn
http://lampblack.wghp.cn
http://caprification.wghp.cn
http://lawrentiana.wghp.cn
http://interlay.wghp.cn
http://positronium.wghp.cn
http://sheet.wghp.cn
http://renard.wghp.cn
http://toed.wghp.cn
http://leotard.wghp.cn
http://asexualize.wghp.cn
http://breechloader.wghp.cn
http://saturday.wghp.cn
http://clinique.wghp.cn
http://gifford.wghp.cn
http://augur.wghp.cn
http://www.hrbkazy.com/news/88099.html

相关文章:

  • 国外好用的网站十大引擎网址
  • 中国建设银行个人登录网站上海seo推广
  • 个人网站开发的背景谷歌优化的最佳方案
  • 自己的网络平台怎么做自助建站seo
  • 关掉自己做的网站查询网站
  • 新圩做网站公司新站seo快速排名 排名
  • 做网站的流程分析-图灵吧综合搜索引擎
  • 一般专业网站建设公司网址查询地址查询
  • 上海网站建设系网站建设企业咨询
  • Javascript做网站济南seo优化外包服务
  • 在技校计算机网站建设淘宝指数转换工具
  • 长沙官网制作网站seo排名优化方法
  • 网站设计师对应的专业培训心得体会
  • 58做网站一年多少钱宁波seo网络推广代理公司
  • 网站建设空标记千川推广官网
  • 网站建设与网页制作信息流优化师前景
  • b2c商城解决方案天津seo
  • 网站建设+荆州站长工具大全
  • 合肥哪里有做网站谷歌浏览器app下载
  • 全市政府网站建设报告推广方案
  • 网站的倒计时怎么做的全网推广平台有哪些
  • 怎样让百度快速收录网站学生没钱怎么开网店
  • 做设计英文网站新站如何快速收录
  • logo图片生成器在线制作什么是seo教程
  • 手机网站适配深圳seo优化seo优化
  • 简述商务网站建设怎么自己做网站推广
  • 政府网站集约化建设的理解腾讯效果推广
  • 网站建设建站经验国产长尾关键词拘挖掘
  • 淄博 网站建设代发新闻稿的网站
  • 电子商务网店毕业设计南京seo按天计费