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;

  • 相关阅读:
    vim 颜色主题设置
    给vim安装YouCompleteMe
    linux的主题与图标
    arch点击硬盘无法挂载
    arch安装完成之后不能使用笔记本自带的无线网卡
    curl的使用
    arch优化开机
    seo成功案例的背后秘密
    网站seo整站优化有什么优势
    企业站如何做长尾关键词seo优化
  • 原文地址:https://www.cnblogs.com/lsxsx/p/13388263.html
Copyright © 2011-2022 走看看