Friday, November 10, 2017

Database View in SQL Server

Standard Views: Most of the time, we create this kind of view where we use single or more that one tables, use JOINs and other clauses and pull the data out. The tables are saved on a single physical file, most of the time on primary data file – that is .mdf file. All tables don’t have any kind of partitions
                          Image result for database views images                                                                             
Indexed Views: Usually views pull the data out from underlying tables and utilise indexes created on table columns. However, an indexed view allows us to create a unique clustered index on it – allowing us to physically keep a separate copy of sorted data based on which column we created a unique clustered index. This dramatically improves the view’s performance for some types of queries. An indexed view works best for queries that are giving summary data. However, this type of view is not recommended in case there is high frequency of data insert, update or delete on underlying table(s).
Image result for indexed views image

Partitioned Views: This type of view joins horizontally partitioned data from a set of members table across one or more servers. We partition a table horizontally and keep data partitions either on one server or on multiple servers (federated servers) in order to gain performance. We may sub-categorize this category into two:
Local Partitioned Views: This joins required tables on the same instance of SQL Server i.e.. same SQL Server engine.

Distributed Partitioned Views: This joins required tables across servers i.e. multiple SQL Server engines.

Image result for Indexed Views in SQL Server

No comments:

Post a Comment

SQL Script to list out name of tables and its records in the database

SET NOCOUNT ON  DBCC UPDATEUSAGE(0)  -- DB size. EXEC sp_spaceused -- Table row counts and sizes. CREATE TABLE #temptable  (      [name] NVA...