• 视图


    视图
    创建视图的sql语句:
    create view user as select a.name,a.age,b.sex from usera as a, userb as b where a.name=b.name;
    定义视图,以V_开头
    create view 视图名称 as select 语句
    查看视图, 查看表会将所有的视图也列出来
    show tables;
    删除视图
    drop view 视图名称
    例如 drop view v_stu_score_course;
    视图的用途就是查询
    select * from v_stu_score_course;

    事物:
    事物四个特性 acid
    原子性 一致性 隔离性 持久性
    事物命令
    表的引擎类型是innodb,mysql表的默认引擎
    查看表的创建语句,可以看到engine=innodb
    show create table students
    修改命令的数据 insert update delete
    begin 开始事务
    commit 提交事务
    rollback 回滚事务

    索引
    查看索引
    show index from 表名
    创建索引
    create table create_index(
    id int primary key,
    name varchar(10) unique,
    age int,
    key (age)
    );
    删除索引
    drop index 索引名称 on 表名
    测试时间
    set profiling=1;#打开sql语句执行时间
    show profiles;#查看sql执行时间

    外键foreign key
    查看外键
    show create table 表名
    添加外键
    alter table students add constraint fk_students_gid foreign key (gid) references grade(gid) on delete cascade;

  • 相关阅读:
    wenbao与powershell
    wenbao与windows
    wenbao与msf
    CCF201612-Python题解
    语不惊人死不休
    为人性僻耽佳句(一)
    Pytorch出现 raise NotImplementedError
    CNN卷积
    python字符串切片
    python----numpy(持续更新)
  • 原文地址:https://www.cnblogs.com/gengyanqi/p/10485343.html
Copyright © 2020-2023  润新知