DataBase/MS SQL
34.MS_SQL 2008 - 카테고리 ( Category ) 응용(2)
Godffs
2009. 9. 15. 11:20
반응형
뷰 부분 수정
--[!] 뷰에다가직접데이터입력
Insert Into GetTopCategory(CategoryName) Values('가전')
Go
Select *From Categories
Go
--[!] 뷰의모든것을변경
Alter View dbo.GetTopCategory
As
Select *
From dbo.Categories
Where SuperCategory Is Null
With Check Option --조건절에해당하는데이터만입력/수정가능
Go
--추가후다시실행하면애러: Identity값입력x, SuperCategory => Null 입력
Insert Into GetTopCategory Values('오디오', 5, 2)
Go
--기본
Set Identity_Insert Categories On
--실행: 조건절이(대분류만가능토록되어있기에)
Insert Into GetTopCategory(CategoryName) Values('오디오') --에러
Go
Insert Into GetTopCategory(CategoriesID, CategoryName) Values(7, '오디오') --실행
Go
Insert Into GetTopCategory(CategoriesID, CategoryName, SuperCategory) Values(8, '오디오', Null) --실행
Go
--뷰삭제
Drop View GetTopCategory
Go
반응형