zoukankan      html  css  js  c++  java
  • 数据库-mysql视图

      视图是一个虚拟表(非真实存在),其本质是【根据SQL语句获取动态的数据集,并为其命名】,用户使用时只需使用【名称】即可获取结果集,并可以将其当作表来使用

    一:创建视图

      create view viewname as select tname from table1,table2 where condition

    MariaDB [test2]> create view student2 as select * from student;
    Query OK, 0 rows affected (0.02 sec)
    
    MariaDB [test2]> show tables;
    +-----------------+
    | Tables_in_test2 |
    +-----------------+
    | a               |
    | b               |
    | student         |
    | student2        |
    +-----------------+
    4 rows in set (0.00 sec)

    二:删除视图

      drop view viewname

    MariaDB [test2]> drop view student2;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [test2]> show tables;
    +-----------------+
    | Tables_in_test2 |
    +-----------------+
    | a               |
    | b               |
    | student         |
    +-----------------+
    3 rows in set (0.00 sec)

    三:修改视图

      alter view viewname as select tname from table1,table2 where condition

      

    MariaDB [test2]> alter view student2 as select * from a;
    Query OK, 0 rows affected (0.00 sec)
  • 相关阅读:
    扩展欧几里得(exgcd)与同余详解
    卡常模板
    文艺平衡树(区间翻转)
    Motto
    PKUWC2019划水记
    【模板】Splay(洛谷P3391)
    【PKUSC2018】最大前缀和
    【PKUWC2018】随机算法
    【PKUWC2018】Slay the Spire
    【PKUWC2018】Minimax
  • 原文地址:https://www.cnblogs.com/lixiang1013/p/7294040.html
Copyright © 2011-2022 走看看