• Mysql--information_scherma(虚拟库)


    什么是视图

    # 讲解:
          视图也可以理解为别名,创建视图关键字:create view as
    
    # 视图基本操作
    · 表格内容
    mysql> select * from student;
    +----+-----------+-----+--------+---------------------+
    | id | name      | age | gender | cometime            |
    +----+-----------+-----+--------+---------------------+
    |  1 | 戴眼睛    |  23 | M      | 2020-07-15 06:59:15 |
    |  2 | 王瘦子    |  28 | M      | 2020-07-15 06:59:49 |
    |  3 | 王胖子    |  24 | M      | 2020-07-15 07:00:16 |
    |  4 | 陈鱼落雁    |  21 | M      | 2020-07-15 07:00:38 |
    |  5 | 高鸡窝    |  21 | M      | 2020-07-15 07:00:57 |
    |  6 | 汤菜鱼    |  22 | F      | 2020-07-15 07:01:12 |
    +----+-----------+-----+--------+---------------------+
    
    ## 简单查询,年龄大于21(此语句需要多次查询,所以后面用到了虚拟视图,方便后续查看)
    mysql> select name age from student where age >21;
    +-----------+
    | age       |
    +-----------+
    | 戴眼睛     |
    | 王瘦子    |
    | 王胖子    |
    | 汤菜鱼    |
    +-----------+
    
    ## 创建虚拟视图
    mysql> create view tcy as select name age from student where age >21;
    Query OK, 0 rows affected (0.00 sec)
    
    ## 查看发现当前库下存在一个新的表,就是方才虚拟视图查看出来结果
    mysql> select * from tcy;
    +-----------+
    | age       |
    +-----------+
    | 戴眼睛     |
    | 王瘦子    |
    | 王胖子    |
    | 汤菜鱼    |
    +-----------+
    4 rows in set (0.00 sec)
    
    

    后续再更新。。。。。

  • 相关阅读:
    服务器新环境搭建笔记
    mysql存储过程中的异常处理
    Maven为不同环境配置打包
    redis 绑定任意ip
    Redis 【Hash】 一句话说明
    Redis 【string】 一句话说明
    Redis 【keys】 一句话说明
    Redis命令参考【EXPIRE】
    Apache Maven 入门篇 ( 下 )
    Apache Maven 入门篇 ( 上 )
  • 原文地址:https://www.cnblogs.com/tcy1/p/13325212.html
Copyright © 2020-2023  润新知