View are virtual tables that are compiled at runtime.Data associated with the views are not physically stored in view,they are present in base tables.In Sql Server we create view for security purpose as it restricts user to view columns actually present in the base tables.In Sql Servre we can create a view using following syntax-
1)System Defined Views:-These views are predefined views present in master database.They are further classified into 3-
a)Information Schema View:-In Sql Server we have around 20 Information Schema View used to display information for database like tables and columns.eg-Information_Schema.Tables,Information_Schema.columns. b)Catalog View :-These were introduced in sql server 2005 and used to show self describing information.eg-Sys.Tables.
c)Dynamic Management View:-These were also introduced in Sql server2005.Thses view give administrative information of database current state.
2)User Defined Views:-These Views are defined by users.They are of 2 types:- a)Simple View:-When we create a view on single table then it is called simple view.eg-
1)We can insert ,update and delete data from simple view only when we have primary key and all not null fields are in view.
2)We can not insert/delete data in complex view we can only update it.
Sql Server has 2 types of views.There are 2 types of views in sql server.CREATE VIEW [dbo].[View_Employee] AS SELECT Emp_ID, Emp_name, Emp_Sal FROM dbo.Employee GO
1)System Defined Views:-These views are predefined views present in master database.They are further classified into 3-
a)Information Schema View:-In Sql Server we have around 20 Information Schema View used to display information for database like tables and columns.eg-Information_Schema.Tables,Information_Schema.columns. b)Catalog View :-These were introduced in sql server 2005 and used to show self describing information.eg-Sys.Tables.
c)Dynamic Management View:-These were also introduced in Sql server2005.Thses view give administrative information of database current state.
2)User Defined Views:-These Views are defined by users.They are of 2 types:- a)Simple View:-When we create a view on single table then it is called simple view.eg-
b)Complex View:-When we create a view on more than one table then it is called a complex view.eg-CREATE VIEW [dbo].[View_Employee] AS SELECT Emp_ID, Emp_name, Emp_Sal FROM dbo.Employee
Note:-CREATE VIEW [dbo].[View_CompleteUser_Details] AS SELECT dbo.tblUserLogins.sno, dbo.Employee.Emp_ID, dbo.tblUserLogins.username, dbo.tblUserLogins.password, dbo.Employee.Emp_name, dbo.Employee.Emp_Sal FROM dbo.tblUserLogins CROSS JOIN dbo.Employee GO
1)We can insert ,update and delete data from simple view only when we have primary key and all not null fields are in view.
2)We can not insert/delete data in complex view we can only update it.
No comments :
Post a Comment