zoukankan      html  css  js  c++  java
  • mySQL笔记1

    create table 表名

    列名 数据类型 是否为空(是否唯一|是否主键|是否外键)
    列名 数据类型 …(最后一列不加逗号)


    create database 数据库名

    insert into 数据库名.表名 values(数据,按列顺序依次填充用逗号隔开)

    insert into 表名(列名,列名)values(要插入的字段数据)

    update 表 set 列=新值,列=新值 where 条件

    delete from 表 where 条件

    select 结果显示列 from 表 where 条件

    select 列名,列名,列名 from 表名 同时查询几列

    降序查询
    order by 列名 desc 降序排列
    oeder by 列名 asc 升序排列

    navicat
    //


    alter table 表名 add primary key(列名)
    alter table 表名 add primary key(列名,列名)组合主键

    唯一性约束 unique 有主键的情况下添加的约束限制
    alter table 表名 add unique(列名)

    外键约束 通过另一个表的某一列来约束我当前表的一列,这一列在主键表要么是唯一列要么是主键;
    alter table 表名 add foreign key(列名) references(主表名(列名))

    聚和函数
    select sum(列名)from 表名 总和

    avg 平均
    max
    min
    count 个数


    drop table 表名 删除表

  • 相关阅读:
    利用反馈字段给帝国cms添加留言板功能(图文教程)
    对程序员的不尊重是中国it产业的悲哀。
    网站原创文章被盗用怎么办?
    Vector
    iptables
    spark geoip
    geoip scala api
    matlab解三元二次方程组
    统计一个目录下所有普通文本文件的总行数
    awk多模式匹配
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/5446385.html
Copyright © 2011-2022 走看看