码迷,mamicode.com
首页 > 数据库 > 详细

SQL视图的创建

时间:2016-03-31 16:31:04      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

create table Fruit_main
(
  Name varchar(20) primary key not null,
  Code varchar(10) not null,
  Chandi varchar(20),
  Jiage numeric(4,2) 
  )
  
  create table Fruit_two
  (
  FmCode varchar(10) not null,
  FtCode varchar(10) not null,
  ShowMessage varchar(200),  
  )
  select* from Fruit_main,Fruit_two 
  
  insert into Fruit_main values(苹果,Fr001,沂源,1.25)
  insert into Fruit_main values(柠檬,Fr002,不详,1.50)
  
  insert into Fruit_two values(Fr001,Ap001,好吃!)
  insert into Fruit_two values(Fr001,Ap002,好脆!)
  insert into Fruit_two values(Fr002,Nm001,好酸!)
  insert into Fruit_two values(Fr002,Nm002,VC多!)
  
  --新建一个视图 1
  create view Fruit_show
  as
  select Name,Chandi,Jiage,ShowMessage
  from Fruit_main a,Fruit_two b
  where  
  a.Code=b.FmCode and a.Name=苹果
  
  --2
  create view Fruit_show1 
  as
  select Name,Chandi,Jiage,ShowMessage
  from Fruit_main a,Fruit_two b
  where  
  a.Code=b.FmCode
  
  select * from Fruit_show1
  select * from Fruit_show

 

SQL视图的创建

标签:

原文地址:http://www.cnblogs.com/zhizhuo-1991/p/5341403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!