美文网首页
MySQL 笔记

MySQL 笔记

作者: 吕志豪 | 来源:发表于2018-01-26 20:45 被阅读0次

    mysql
    create database mydatabase;
    use database;
    show database;
    drop database;
    select database();
    select version();
    desc tablename;
    net start mysql
    net stop mysql
    DQL select
    DML insert updata delete
    DDL create
    TCL commit rollback
    DCL grant revoke
    source c://data.sql
    ctrl+c
    show create table orz;
    select name '姓名' from driver;
    <> !=
    between small and big
    is null
    ifnull(name,2)
    select 8 from driver where name like '_A%'
    order by money asc/desc 升降
    order by 1 asc/desc 升降
    lower(name)
    upper(name)
    lenth(name)
    substr(name,2,3)
    round (123.456,0)
    rand()
    trim(' wqeqw ')
    str_to_date('日期字符串',‘日期格式’)
    %Y %m %d %H %i %s
    select time from timetable where data=str_to_date('12-7-1980','%m-%d-%Y')
    date_format('日期格式类型数据',‘日期格式’)
    sum()
    avg()
    max()
    count()
    count(*)
    min()
    select distinct name from tablename;
    select distinct name,age from tablename;
    create table emp1 as select * from emp;
    insert into emp select * from emp1;
    alter table t_student add name varchar(10);
    alter table t_student motify name varchar(20);
    alter table t_student drop name
    not null
    unique 不能重复,但可为null unique(name,age)联合表级约束,联合唯一
    primary key
    foreign key
    constaint user_name_unique unique(name)给约束起名字
    外键字段可以为空,被引用表字段必须要有唯一性
    constraint student_class_fk foreign key(classno) references class(cno)
    show engeins;
    start transaction;
    commit;
    rollback;
    set autocommit=off/on;
    set session autocommit=off/on

    相关文章

      网友评论

          本文标题:MySQL 笔记

          本文链接:https://www.haomeiwen.com/subject/xvowaxtx.html