zoukankan      html  css  js  c++  java
  • 视图

    视图的优点:集中分散的数据,简化查询语句,重用SQL语句,保护数据安全,共享所需数据,更改数据格式      //视图: 数据库对象

    mysql-> create or replace view mysql_test.cust_view

        ->  as 

        ->  select * from mysql_test.cust

        ->  where cust_sex='M'

        ->  with check option;     //保证今后对该视图的修改都必须符合客户性别为男性这个条件

    mysql-> drop view if exists mysql_test.cust_view

    mysql-> alter view mysql_test.cust_view  //与创建视图只是相差关键字alter

        ->  as 

        ->  select * from mysql_test.cust

        ->  where cust_sex='M'

        ->  with check option;  

    mysql-> show create view mysql_test.cust_view;

    mysql-> insert into mysql_test.cust_view      //使用insert语句通过视图向基本表插入数据 原表会变

        ->  values(909,'周明','M','武汉市','洪山区'); 

    mysql-> update mysql_test.cust_view

        ->  set cust_address='上海市';

    mysql-> delete from mysql_test.cust_view  //牵扯到多表的话,不能用delete语句了

        ->  where cust_name='周明';

    mysql-> select cust_name,cust_address

        ->  from mysql_test.cust_view

        ->  where cust_id  =905;

  • 相关阅读:
    1058 A+B in Hogwarts (20)
    1036. Boys vs Girls (25)
    1035 Password (20)
    1027 Colors in Mars (20)
    1009. Product of Polynomials (25)
    1006. Sign In and Sign Out
    1005 Spell It Right (20)
    1046 Shortest Distance (20)
    ViewPager页面滑动,滑动到最后一页,再往后滑动则执行一个事件
    IIS7.0上传文件限制的解决方法
  • 原文地址:https://www.cnblogs.com/lsxsx/p/13388263.html
Copyright © 2011-2022 走看看