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

sql server 视图的操作

时间:2015-01-06 15:03:13      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

-- 判断要创建的视图名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N‘[dbo].[视图名]‘) and OBJECTPROPERTY(id, N‘IsView‘) = 1)
-- 删除视图
drop view [dbo].[视图名]
GO

--例子:

--删除视图
drop view GetFinanceLogView
--创建视图
Create view GetFinanceLogView
WITH SCHEMABINDING
as
select ID,OutCashAccountNo ,InCashAccountNo,Amount,RemarkContent,Type,Status,AddTime,RunWater,OperationType from dbo.FinanceLog

--建立索引
if (exists (select * from sys.indexes where name = ‘idx_prod_ProductProgress_Sht‘))
drop index GetFinanceLogView.idx_prod_ProductProgress_Sht
go
create UNIQUE CLUSTERED index idx_prod_ProductProgress_Sht
on
GetFinanceLogView(ID);

sql server 视图的操作

标签:

原文地址:http://www.cnblogs.com/yangjinwang/p/4205859.html

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