15、SQL基础整理(视图)
视图
即虚拟表
系统-右键-新建视图


编辑前200行

select *from studentscore

代码创建法:
create view studentscore
as
select student.sno,sname,ssex,sbirthday,class,cno,degree from student
join score on student.Sno=score.sno
删除视图:
drop view studentscore
修改视图:
alter view cts
as
select student.sno,score.cno,sname,sbirthday,class,cname,tno,degree from student,course,score
where score.Cno=course.Cno and score.sno=student.Sno
Notice:
1、一个视图不能引用另一视图(不能用join链接)
2、order by前面必须写上top
3、修改视图的几个原则:
1)修改视图会直接修改到基表。
2)如果在查询视图时有查询条件和 with check option ,在修改时需要在条件范围内修改,否则报错。
4、删除表时应该明确删除引用该表的视图,否则不会自动删除。
15、SQL基础整理(视图)的更多相关文章
- 必杀技———SQL基础整理系列(一)
SQL(Structured Query Language)——结构化查询语言 SQL语言的组成部分 数据定义语言 (DDL:Data Definition Language) 负责数据结构定义与数据 ...
- 16、SQL基础整理(触发器.方便备份)
触发器(方便备份) 本质上还是一个存储过程,只不过不是通过exec来调用执行,而是通过增删改数据库的操作来执行(可以操作视图) 全部禁用触发器 alter table teacher disable ...
- 14、SQL基础整理(存储过程)
存储过程procedure(proc) 数据库—可编程性—存储过程 新建存储过程: create proc firstproc as select *from fenshu go 执行存储过程: 存储 ...
- 11、SQL基础整理(变量)
变量 定义变量:declare @hello varchar(20) 赋值:set @hello = ‘你好’ select(结果框显示)/print(消息框显示) @hello *三行必须同时 ...
- 9、SQL基础整理(两表连接exists,join on,union)
exists的用法 select *from haha where exists (select *from bumen where bumen.code = haha.bumen and bumen ...
- 8、SQL基础整理(约束)
约束 主键约束 防止在新增数据时出错,有约束性,起唯一标志的作用,在新增条目的时候防止不慎添加重复内容(不允许有null值) 1. 右键—设计—设置主键 2.在创建表格时设置 code int pr ...
- 5、SQL基础整理(字符串函数)
字符串函数 ASCII 返回字符串首字母的ascii编码 select ASCII('name') select ASCII(name) from xuesheng select *from xues ...
- 17、SQL基础整理(事务)
事务 事务==流程控制 确保流程只能成功或者失败,若出现错误会自动回到原点 例: begin tran insert into student values('111','王五','男','1999- ...
- 13、SQL基础整理(流程控制begin……end)
流程控制 begin ……end将一个语句块包含起来,中间可以写任何语句 格式: begin--开始 select *from student end--结束 if declare @bianlian ...
随机推荐
- MVC之URL路由
注册路由规则集合 一个 Web 应用具有一个全局的路由表,该路由表通过 System. Web.Routing.RouteTable的静态只读属性 Routes 表示,该属性返回一个类型为 Syste ...
- 转载python2进制打包相关
Python模块——struct(字节流,组包拆包实现) http://www.linuxidc.com/Linux/2014-02/97158.htm [日期:2014-02-24] 来源:Linu ...
- 源码编译Chrome
官网描述 http://www.chromium.org/developers/how-tos/build-instructions-windows 为啥还要写这篇博客 太久没在这里写博客 Chrom ...
- 7款适用老旧设备并对初学者非常友好的轻量级Linux发行版
我们由从 7 到 1 的顺序向大家介绍. 7. Linux Lite 正如其名,Linux Lite 是 Linux 发行版的一个轻量级版本,用户并不需要强大的硬件就可以将它跑起来,而且其使用非常简单 ...
- 如何管理好项目的DLL
.net fx自带的dll net fx自带的dll,直接添加,注意.net fx版本即可. 第三方类库 如果是第三方类库,使用NuGet从NuGet官网下载,比如json.net,jQuery等. ...
- Qml一些技巧
1.从ListView中获取当前选中项 myList.currentItem.children[0].text 可以获取ListView的选择项的一个个元素.注意children的使用.
- android 启动时的短暂黑屏解决
http://blog.csdn.net/lonely_fireworks/article/details/22291835 http://www.cnblogs.com/henanjing/arch ...
- 在完成一个异步任务后取消剩余任务(C#)
完整实例 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System. ...
- linux 执行php文件
/opt/php5/bin/php /home/Xcar/tag/interface/tag_api4hbase.php tag_export2file "/tmp/guo.php" ...
- swift 开眼今日精选
swift 开眼今日精选 import UIKit class TodayController: UITableViewController { vararray =NSMutableArray() ...