zoukankan      html  css  js  c++  java
  • mysql学习笔记

    create table day9_work(
    id int auto_increment comment '编号',
    compensation float comment '薪资',
    postcode char(6) comment '邮编',
    name varchar(20) comment '姓名',
    birthday datetime comment '出生具体时间',
    birthdayday date comment '出生日期',
    intro text comment '介绍',
    sex enum('男','女') comment '性别',
    hobby set('台球','篮球','足球') comment '爱好',
    primary key(id),
    key(name)
    ) engine=innodb,charset=utf8;
    alter table day9_work add age int default 18;
    alter table day9_work change postcode postcode char(10) comment '邮编';
    alter table day9_work rename day9_workrename;
    create table day9_workrename2 like day9_workrename;
    insert into day9_workrename values(3,2.4,'12345','mpc','1995-9-28 15:34:00','1995/9/28','my name is mpc','男','台球,篮球','21');
    insert into day9_workrename values(null,2.4,'12345','mpc2','1995-9-28 15:34:00','1995/9/28','my name is mpc2','男',5,'21');
    insert into day9_workrename2 select * from day9_workrename;

    数据库设计:
    1NF:要求数据达到原子性使数据不可再分:

    2NF:要求数据每一行具有唯一性(保证数据不重复),消除数据部分依赖:


    主键一定决定其他字段,其他字段一定依赖于主键;

    消除部分依赖就是保证完全依赖;

    改进:

    3NF:独立性,消除传递依赖:

    改进:

    数据操作语言:

    数据查询语言:
    基本查询:

    day10_work:

    create table day10_work(
    商品ID int,
    商品名称 varchar(100),
    类型ID int,
    商品价格 int,
    商品品牌 varchar(20),
    商品产地 varchar(20),
    primary key(商品ID)
    );
    insert into day10_work(商品ID,商品名称,类型ID,商品价格,商品品牌,商品产地) values
    (1,'康佳(KONKA)42英寸全高清液晶电视',1,1999,'康佳','深圳');
    insert into day10_work(商品ID,商品名称,类型ID,商品价格,商品品牌,商品产地) values
    (15,'惠普(HP)黑白激光打印机',3,1169,'惠普','天津'),
    (3,'海信(Hisense)55英寸智能电视',1,4199,'海信','青岛'),
    (2,'索尼(SONY)4G手机(黑色)',2,3238,'索尼','深圳'),
    (5,'索尼(SONY)13.3英寸触控超级本',3,11499,'索尼','天津'),
    (11,'索尼(SONY)60英寸全高清液晶电视',1,6999,'索尼','北京'),
    (12,'联想(Lenovo)14.0英寸笔记本电脑',3,2999,'联想','北京'),
    (13,'联想 双卡双待3G手机',2,988,'联想','北京'),
    (4,'联想(Lenovo)14.0英寸笔记本电脑',3,5499,'联想','北京');

    select * from day10_work order by 商品价格 desc limit 0,1;
    select 类型ID from day10_work order by 类型ID desc limit 0,1;
    select * from day10_work order by 商品价格 asc limit 0,1;
    select 类型ID from day10_work order by 类型ID asc limit 0,1;
    select count(*) as 商品数量总和 from day10_work;
    select avg(商品价格) as 平均价格 from day10_work;
    select avg(商品价格) as 联想品牌平均价格 from day10_work where 商品品牌='联想';
    select * from day10_work order by 商品价格 desc;
    select * from day10_work order by 类型ID desc,商品价格 asc;
    select * from day10_work order by 商品价格 desc limit 0,3;
    select 商品产地,count(*) as 每个产地各有的数量 from day10_work group by 商品产地;
    select 商品品牌,count(*) as 每个品牌各有的数量 from day10_work group by 商品品牌;

    day11作业:

  • 相关阅读:
    TensorFlow(五):手写数字识别加强版
    TensorFlow(四):手写数字识别
    TensorFlow(三):非线性回归
    Apache+php搭建
    PHP基础知识(1)
    mysql8.0.11安装
    ffmpeg-20160517-git-bin-v2
    ffmpeg-20160517-git-bin
    Node.js 字体格式转换 ttf2eot ttf2woff ttf2svg
    ffmpeg-20160515-git-bin
  • 原文地址:https://www.cnblogs.com/mapingchuan/p/7608317.html
Copyright © 2011-2022 走看看