zoukankan      html  css  js  c++  java
  • 数据库简总

    数据库
    作用:存放数据
     
    mysql关系型数据库管理学系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。
     
    目前主流数据库:
    微软:aqlServer access
    Oracle:Oracle mysql java
    IBM公司:db2
    Sybase公司:Sybase-jt
    mycql -uroot -p安装完成与否
    net start mycql
    nat stop mycql
    servises.msc
    show databases; //展现有那些库
    create database; 创建库
    drop database 库名;删除
    创表:create table 表明(字段名 类型,);
    alter table student add Address 。。。。
    alter table 库名 drop
    alter table change
     
    索引:create idex 名字 on 表 (列名)
    删除索引:alter table<表名> drop
     
    数据库中的存储形式
     
    1.层次模型
     
     
    2、网状模型
     
    3、关系模型(重点)
     
    has a
    use a
    is a
     
     
    DECIMAL
     
    数据库完整性:防止垃圾数据产生
     
    主键约束:
    create table student(
    stu_id INT PRIMARY key auto_increment,
    stu_name VARCHAR(20) NOT NULL,
    stu_gender INT CHECK(stu_gender=1 or stu_gender=0),
    stu_address VARCHAR(20),
    stu_class
    )
    关联关系:删除,先删从犯标
    1v1:
    ---唯一外键关联(外键设计在任意一个字符串上设计,但是有唯一约束)
    ---主键关联
    1对多:外键必须设计发哦
    多对多;外键设计在中jian
     
    sql语句
    1、
    ---DDL:数据定义语言(建立删除修改,ttable修改、删除表结构)(数据库设计人员做)
    ---DQL:查询语句
    ---DML:增删改语句
    ---DCL :控制语言
     
    增:insert into 表明(列名) values(值)
    改:update 表明 set 列=新值 where 过滤条件
    删:delete from 表名 where过滤条件
    查:投影:select from
    select +(distinct)+ from 表名 where条件 order by 列1列2
    不建议用select * 查询全部,这样效率很低
    concat 可以连接字符串concat(列1名,'+'。列,名2)
    distinct:用于排除重复的行数据
    limit:限制看多少条,limit 0,10
    where and并且 or或者 between and(大于等于下线并且小于等于上线)
    指定某值,列名 in()
    where 列 like‘ ’ %表示零个到任意个 _表示一个字
    is null 或者is not null 判断是否为空
     
    order by +列:对列进行排序 默认(asc)升序 加desc降序排
     
    1、来自罗马俱乐部的90后后卫
    2、曼联俱乐部有一个马字的球员
    3、名字中带有巴的俱乐部和位置
    4、90后来自曼联的中锋
    5、同一天出生的球员
     
    聚合函数:
    count:统计行数量 select count() from
    *所有
    all表示指定统计列非空值行数
    aidtinct排除重复项
     
    sum:列值求和
    没有*;
     
    avg:列平均数
    没有*
     
    max:最大
    min:最小
     
    group by 分组
     
    having +过滤条件(分组以后筛选::::where分组前筛选)
     
     
    多表操作
    子查询:嵌套在主查询中的查询
    select中嵌套查询:效率低
     
    子查询嵌套在select中效率低,实际开发中尽量使用表连接的方式取代(尽针对于嵌套在select中)
    from中嵌套子查询:
    多行多列
    while嵌套
    单行单列
    in
    not in 单列
    all运算符:逐一比较,全面满足满足
    any运算符:一条满足,就满足条件
     
    exsits 存在
    not exsts 不存在
     
    组合查询union
     
     
  • 相关阅读:
    Ubuntu 14.04 卸载通过源码安装的库
    Ubuntu 14.04 indigo 相关依赖
    Ubuntu 14.04 indigo 安装 cartographer 1.0.0
    Ubuntu 14.04 改变文件或者文件夹的拥有者
    安装cartographer遇到Unrecognized syntax identifier "proto3". This parser only recognizes "proto2"问题
    Unrecognized syntax identifier "proto3". This parser only recognizes "proto2". ”问题解决方法
    查看所有用户组,用户名
    1卸载ROS
    Ubuntu14.04 软件安装卸载
    Ubuntu14.04系统显示器不自动休眠修改
  • 原文地址:https://www.cnblogs.com/houxi1234/p/6505500.html
Copyright © 2011-2022 走看看