美文网首页
MySQL自学day4.视图,存储过程(函数)

MySQL自学day4.视图,存储过程(函数)

作者: Clemente | 来源:发表于2017-11-25 15:27 被阅读1次

    新建视图 点击视图 ctrl+s保存

    SELECT s_id,s_name,s_class from student
    
    image.png
    image.png
    脚本语句
    视图

    视图的查询


    image.png

    视图的脚本语句的创建

    create view newview as select * from student
    
    image.png
    image.png

    视图与表之间能互相影响,同步数据改变 但很少用视图去修改元数据

    存储过程(函数)
    选函数

    BEGIN
         SELECT count(*)into zongshu from student where s_sex = '男';
    END
    
    image.png
    image.png
    BEGIN
    if sex then 
            select count(*) into shu from student where s_sex = '女';
    else 
            select count(*) into shu from student where s_sex = '男';
    end if;
    END
    
    image.png

    相关文章

      网友评论

          本文标题:MySQL自学day4.视图,存储过程(函数)

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