SlideShare uma empresa Scribd logo
1 de 29
 A view is an "VirtualTable".
 It can have multiple columns and rows from the
one or more table.
 Normally view cannot store the data
permanently in the table.
 Views display only those data which are
mentioned in the query.
 A view consists of a SELECT statement
 Views are used as Security Mechanism of Database.
 A view can be useful when there are multiple users with different levels
of access, who all need to see portions of the data in the database.
 Views can do the following:
 Restrict access to specific rows in a table
 Restrict access to specific columns in a table
 Join columns from multiple tables and present them as though they
are part of a single table
 Present aggregate information (such as the results of the COUNT
function).
‘EmpInfo’Table:
General syntax for creating a view:
CREATEVIEW [View_Name]
AS
[SELECT Statement]
As for example :
CREATEVIEW SampleView
As
SELECT EmpID, EmpName FROM
EmpInfo
 This is as similar as select statement of a
table.
SELECT * FROM SampleView
 General syntax:
DROPVIEW viewname;
 Example:
DROPVIEW SampleView;
 When a view is dropped, it has no effect on the underlying
tables.
 Dropping a view removes its definition and all the
permissions assigned to it.

 However, dropping a table that references a view does not
drop the view automatically.
 You must drop it explicitly.
 General syntax:
ALTERVIEW viewname
AS
SELECT…;
 Example:
ALTERVIEW SampleView
AS
SELECT * FROM EmpInfo;
The value for the column is provided
automatically if:
 The column has an IDENTITY property.
 The column has a default value specified.
 The column has a timestamp data type.
 The column takes null values.
 The column is a computed column.
 The value of a column with an IDENTITY
property cannot be updated.
 Records cannot be updated if the base table
contains aTIMESTAMP column.
 While updating a row, if a constraint or rule is
violated, the statement is terminated, an error is
returned, and no records are updated.
 When there is a self-join with the same view or
base table, the UPDATE statement does not
work.
 There are 3 methods to see the view definition:
 Method 1:
Sp_helptext viewname;
 Method 2:
select definition from sys.sql_modules
where object_id=object_id(‘viewname');
 Method 3:
select object_definition(object_id('vv'));
 The sys.sql_modules is a system view. It is
used to display view definition.
 Object_definition() is built-in function that
returns the view definition.
 Object_id() is a system function that returns
the ID of view.
 There are two types of views in the sql server
2005.
 Normal or Standard view
 Partitioned view
 This view is most frequently used by the
developers.
 When we create the view the schema will be
stored as object in the database.
 When we retrieve the content from this virtual
table, it will execute the schema and the stored
data from the parent table.
 These include focusing on specific data and
simplifying data manipulation.
 CREATEVIEW vw_empinfo
AS
SELECT * FROM EmpInfo;
 SELECT * FROM vw_empinfo;
 INSERT INTO vw_empinfo
VALUES(4,’abcd’,’.NET’,565652);
 DELETE FROM vw_empinfo WHERE EmpID = 1;
Here you can do the DML operations in the view when you
have only one table.
 The partitioned view and its execution is like
normal view.
 It will work across the database and across
the server.
 There are two types of Partitioned views.
 Local PartitionedView
 Global PartitionedView
 The local partitioned view can be created
within same server but different database.
 The view schema definition will be stored in
the executed database.
 USE Database1
CREATETABLE EmployeeList
(
iEmployeeID INT IDENTITY(1,1),
vFirstNameVARCHAR(25) NOT NULL,
vLastNameVARCHAR(25) NOT NULL,
iDeptID INT
)
 USE Database2
CREATETABLE Department
(
iDeptID INT IDENTITY(1,1) PRIMARY KEY,
vDeptNameVARCHAR(50),
)
CREATEVIEW vw_LocalPartion_View
AS
SELECT E.iEmployeeID, D.vDeptName
FROM EmployeeList E
INNER JOIN
Database2.dbo.Department D ON D.iDeptID = E.iDeptID ;
 The global Partitioned view will work across the server.
 The view can be created to join the table across the server.
 The accessing format will be like this.
[Server Name]. Database Name.Table Name
 When we execute the view if it is not linked with the current
server then it will ask us to link the external server.
 The following system stored procedure will be used
to link the server.
sp_addlinkedserver 'Server name'
 The following system catalog table is used to see
the list of linked servers.
SELECT * FROM SYS.SERVERS
 There are two different option for creating a
view.
 Schema Binding Option
 Encryption
 If we Creates a view with the SCHEMABINDING option it will
locks the tables being referred by the view and restrict any
kinds of changes that may change the table schema ( No
Alter Command) .
 While creating schema binding view, we can't mention
"Select * from tablename" with the query.
 We have to mention all the column name for reference
CREATEVIEW DemoSampleView
With SCHEMABINDING
As
SELECT EmpID, EmpName, FROM DBO.EmpInfo;
 While specifying the Database name we have
use Dbo.[DbName] .
 This will prevent any of the underlying tables
from being altered without the view being
dropped.
 This option encrypts the definition.
 This option encrypts the definition of the view.
 Users will not be able to see the definition of
theView after it is created.
 This is the main adavatages of view where we
can make it secure.
 Note: Once view is encrypted, there is no way
to decrypt it again.
CREATEVIEW DemoView
With ENCRYPTION
Select ename,edesig from dbo.EmpInfo

Mais conteúdo relacionado

Mais procurados (14)

Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
 
Prabu's sql quries
Prabu's sql quries Prabu's sql quries
Prabu's sql quries
 
Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
SQL Functions - Oracle SQL Fundamentals
SQL Functions - Oracle SQL FundamentalsSQL Functions - Oracle SQL Fundamentals
SQL Functions - Oracle SQL Fundamentals
 
Sql commands
Sql commandsSql commands
Sql commands
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
 
View
ViewView
View
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Rapid postgresql learning, part 3
Rapid postgresql learning, part 3
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 

Destaque

Creative Play UK- The Outdoor Play Experts
Creative Play UK- The Outdoor Play ExpertsCreative Play UK- The Outdoor Play Experts
Creative Play UK- The Outdoor Play ExpertsPaul Gambino
 
Manuel de survie de l'Innovateur
Manuel de survie de l'InnovateurManuel de survie de l'Innovateur
Manuel de survie de l'InnovateurSimon Guimezanes
 
Release Planning Days - The story of a ritual @ Meetic
Release Planning Days - The story of a ritual @ MeeticRelease Planning Days - The story of a ritual @ Meetic
Release Planning Days - The story of a ritual @ MeeticMarika Prince, PMP
 
Problem Interview exercice for OCTO meetup
Problem Interview exercice for OCTO meetupProblem Interview exercice for OCTO meetup
Problem Interview exercice for OCTO meetupFranck Debane
 
The Outlook For Telehealth And CSP Early Movers
The Outlook For Telehealth And CSP Early MoversThe Outlook For Telehealth And CSP Early Movers
The Outlook For Telehealth And CSP Early MoversSherrie Xiaoyu HUANG
 

Destaque (7)

Creative Play UK- The Outdoor Play Experts
Creative Play UK- The Outdoor Play ExpertsCreative Play UK- The Outdoor Play Experts
Creative Play UK- The Outdoor Play Experts
 
Manuel de survie de l'Innovateur
Manuel de survie de l'InnovateurManuel de survie de l'Innovateur
Manuel de survie de l'Innovateur
 
Release Planning Days - The story of a ritual @ Meetic
Release Planning Days - The story of a ritual @ MeeticRelease Planning Days - The story of a ritual @ Meetic
Release Planning Days - The story of a ritual @ Meetic
 
PeopleLink Corporate Brochure-2016
PeopleLink Corporate Brochure-2016PeopleLink Corporate Brochure-2016
PeopleLink Corporate Brochure-2016
 
Problem Interview exercice for OCTO meetup
Problem Interview exercice for OCTO meetupProblem Interview exercice for OCTO meetup
Problem Interview exercice for OCTO meetup
 
The Outlook For Telehealth And CSP Early Movers
The Outlook For Telehealth And CSP Early MoversThe Outlook For Telehealth And CSP Early Movers
The Outlook For Telehealth And CSP Early Movers
 
мультимедіа1
мультимедіа1мультимедіа1
мультимедіа1
 

Semelhante a Sql server ___________session_16(views)

Semelhante a Sql server ___________session_16(views) (20)

Module05
Module05Module05
Module05
 
Designing and Creating Views, Inline Functions, and Synonyms
 Designing and Creating Views, Inline Functions, and Synonyms Designing and Creating Views, Inline Functions, and Synonyms
Designing and Creating Views, Inline Functions, and Synonyms
 
Les10
Les10Les10
Les10
 
Les11
Les11Les11
Les11
 
Oracle view
Oracle viewOracle view
Oracle view
 
Sql viwes
Sql viwesSql viwes
Sql viwes
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
View
ViewView
View
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sql
 
MySql: Queries
MySql: QueriesMySql: Queries
MySql: Queries
 
MySQL Queries
MySQL QueriesMySQL Queries
MySQL Queries
 
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbdsfoodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
Sq lite
Sq liteSq lite
Sq lite
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactions
 
MS SQL SERVER: Creating Views
MS SQL SERVER: Creating ViewsMS SQL SERVER: Creating Views
MS SQL SERVER: Creating Views
 
MS SQLSERVER:Creating Views
MS SQLSERVER:Creating ViewsMS SQLSERVER:Creating Views
MS SQLSERVER:Creating Views
 

Mais de Ehtisham Ali

Sql server ___________session_20(ddl triggers)
Sql server  ___________session_20(ddl triggers)Sql server  ___________session_20(ddl triggers)
Sql server ___________session_20(ddl triggers)Ehtisham Ali
 
Sql server ___________session3-normailzation
Sql server  ___________session3-normailzationSql server  ___________session3-normailzation
Sql server ___________session3-normailzationEhtisham Ali
 
Sql server ___________session2-data_modeling
Sql server  ___________session2-data_modelingSql server  ___________session2-data_modeling
Sql server ___________session2-data_modelingEhtisham Ali
 
Sql server ___________session_19(triggers)
Sql server  ___________session_19(triggers)Sql server  ___________session_19(triggers)
Sql server ___________session_19(triggers)Ehtisham Ali
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)Ehtisham Ali
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)Ehtisham Ali
 
Sql server ___________session_15(data integrity)
Sql server  ___________session_15(data integrity)Sql server  ___________session_15(data integrity)
Sql server ___________session_15(data integrity)Ehtisham Ali
 
Sql server ___________session_11-12(joins)
Sql server  ___________session_11-12(joins)Sql server  ___________session_11-12(joins)
Sql server ___________session_11-12(joins)Ehtisham Ali
 
Sql server ___________session_10(group by clause)
Sql server  ___________session_10(group by clause)Sql server  ___________session_10(group by clause)
Sql server ___________session_10(group by clause)Ehtisham Ali
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-introEhtisham Ali
 
Sql server ___________session 3(sql 2008)
Sql server  ___________session 3(sql 2008)Sql server  ___________session 3(sql 2008)
Sql server ___________session 3(sql 2008)Ehtisham Ali
 
Sql server ___________session 2(sql 2008)
Sql server  ___________session 2(sql 2008)Sql server  ___________session 2(sql 2008)
Sql server ___________session 2(sql 2008)Ehtisham Ali
 
Sql server ___________session 1(sql 2008)
Sql server  ___________session 1(sql 2008)Sql server  ___________session 1(sql 2008)
Sql server ___________session 1(sql 2008)Ehtisham Ali
 
Sql server ___________data type of sql server
Sql server  ___________data type of sql serverSql server  ___________data type of sql server
Sql server ___________data type of sql serverEhtisham Ali
 
Sql server ___________data control language
Sql server  ___________data control languageSql server  ___________data control language
Sql server ___________data control languageEhtisham Ali
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)Ehtisham Ali
 

Mais de Ehtisham Ali (17)

Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Sql server ___________session_20(ddl triggers)
Sql server  ___________session_20(ddl triggers)Sql server  ___________session_20(ddl triggers)
Sql server ___________session_20(ddl triggers)
 
Sql server ___________session3-normailzation
Sql server  ___________session3-normailzationSql server  ___________session3-normailzation
Sql server ___________session3-normailzation
 
Sql server ___________session2-data_modeling
Sql server  ___________session2-data_modelingSql server  ___________session2-data_modeling
Sql server ___________session2-data_modeling
 
Sql server ___________session_19(triggers)
Sql server  ___________session_19(triggers)Sql server  ___________session_19(triggers)
Sql server ___________session_19(triggers)
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)
 
Sql server ___________session_15(data integrity)
Sql server  ___________session_15(data integrity)Sql server  ___________session_15(data integrity)
Sql server ___________session_15(data integrity)
 
Sql server ___________session_11-12(joins)
Sql server  ___________session_11-12(joins)Sql server  ___________session_11-12(joins)
Sql server ___________session_11-12(joins)
 
Sql server ___________session_10(group by clause)
Sql server  ___________session_10(group by clause)Sql server  ___________session_10(group by clause)
Sql server ___________session_10(group by clause)
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-intro
 
Sql server ___________session 3(sql 2008)
Sql server  ___________session 3(sql 2008)Sql server  ___________session 3(sql 2008)
Sql server ___________session 3(sql 2008)
 
Sql server ___________session 2(sql 2008)
Sql server  ___________session 2(sql 2008)Sql server  ___________session 2(sql 2008)
Sql server ___________session 2(sql 2008)
 
Sql server ___________session 1(sql 2008)
Sql server  ___________session 1(sql 2008)Sql server  ___________session 1(sql 2008)
Sql server ___________session 1(sql 2008)
 
Sql server ___________data type of sql server
Sql server  ___________data type of sql serverSql server  ___________data type of sql server
Sql server ___________data type of sql server
 
Sql server ___________data control language
Sql server  ___________data control languageSql server  ___________data control language
Sql server ___________data control language
 
Sql server ___________ (advance sql)
Sql server  ___________  (advance sql)Sql server  ___________  (advance sql)
Sql server ___________ (advance sql)
 

Último

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 

Último (20)

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 

Sql server ___________session_16(views)

  • 1.
  • 2.  A view is an "VirtualTable".  It can have multiple columns and rows from the one or more table.  Normally view cannot store the data permanently in the table.  Views display only those data which are mentioned in the query.  A view consists of a SELECT statement
  • 3.
  • 4.  Views are used as Security Mechanism of Database.  A view can be useful when there are multiple users with different levels of access, who all need to see portions of the data in the database.  Views can do the following:  Restrict access to specific rows in a table  Restrict access to specific columns in a table  Join columns from multiple tables and present them as though they are part of a single table  Present aggregate information (such as the results of the COUNT function).
  • 6. General syntax for creating a view: CREATEVIEW [View_Name] AS [SELECT Statement] As for example : CREATEVIEW SampleView As SELECT EmpID, EmpName FROM EmpInfo
  • 7.  This is as similar as select statement of a table. SELECT * FROM SampleView
  • 8.  General syntax: DROPVIEW viewname;  Example: DROPVIEW SampleView;
  • 9.  When a view is dropped, it has no effect on the underlying tables.  Dropping a view removes its definition and all the permissions assigned to it.   However, dropping a table that references a view does not drop the view automatically.  You must drop it explicitly.
  • 10.  General syntax: ALTERVIEW viewname AS SELECT…;  Example: ALTERVIEW SampleView AS SELECT * FROM EmpInfo;
  • 11. The value for the column is provided automatically if:  The column has an IDENTITY property.  The column has a default value specified.  The column has a timestamp data type.  The column takes null values.  The column is a computed column.
  • 12.  The value of a column with an IDENTITY property cannot be updated.  Records cannot be updated if the base table contains aTIMESTAMP column.  While updating a row, if a constraint or rule is violated, the statement is terminated, an error is returned, and no records are updated.  When there is a self-join with the same view or base table, the UPDATE statement does not work.
  • 13.  There are 3 methods to see the view definition:  Method 1: Sp_helptext viewname;  Method 2: select definition from sys.sql_modules where object_id=object_id(‘viewname');  Method 3: select object_definition(object_id('vv'));
  • 14.  The sys.sql_modules is a system view. It is used to display view definition.  Object_definition() is built-in function that returns the view definition.  Object_id() is a system function that returns the ID of view.
  • 15.
  • 16.  There are two types of views in the sql server 2005.  Normal or Standard view  Partitioned view
  • 17.  This view is most frequently used by the developers.  When we create the view the schema will be stored as object in the database.  When we retrieve the content from this virtual table, it will execute the schema and the stored data from the parent table.  These include focusing on specific data and simplifying data manipulation.
  • 18.  CREATEVIEW vw_empinfo AS SELECT * FROM EmpInfo;  SELECT * FROM vw_empinfo;  INSERT INTO vw_empinfo VALUES(4,’abcd’,’.NET’,565652);  DELETE FROM vw_empinfo WHERE EmpID = 1; Here you can do the DML operations in the view when you have only one table.
  • 19.  The partitioned view and its execution is like normal view.  It will work across the database and across the server.  There are two types of Partitioned views.  Local PartitionedView  Global PartitionedView
  • 20.  The local partitioned view can be created within same server but different database.  The view schema definition will be stored in the executed database.
  • 21.  USE Database1 CREATETABLE EmployeeList ( iEmployeeID INT IDENTITY(1,1), vFirstNameVARCHAR(25) NOT NULL, vLastNameVARCHAR(25) NOT NULL, iDeptID INT )  USE Database2 CREATETABLE Department ( iDeptID INT IDENTITY(1,1) PRIMARY KEY, vDeptNameVARCHAR(50), )
  • 22. CREATEVIEW vw_LocalPartion_View AS SELECT E.iEmployeeID, D.vDeptName FROM EmployeeList E INNER JOIN Database2.dbo.Department D ON D.iDeptID = E.iDeptID ;
  • 23.  The global Partitioned view will work across the server.  The view can be created to join the table across the server.  The accessing format will be like this. [Server Name]. Database Name.Table Name  When we execute the view if it is not linked with the current server then it will ask us to link the external server.
  • 24.  The following system stored procedure will be used to link the server. sp_addlinkedserver 'Server name'  The following system catalog table is used to see the list of linked servers. SELECT * FROM SYS.SERVERS
  • 25.  There are two different option for creating a view.  Schema Binding Option  Encryption
  • 26.  If we Creates a view with the SCHEMABINDING option it will locks the tables being referred by the view and restrict any kinds of changes that may change the table schema ( No Alter Command) .  While creating schema binding view, we can't mention "Select * from tablename" with the query.  We have to mention all the column name for reference
  • 27. CREATEVIEW DemoSampleView With SCHEMABINDING As SELECT EmpID, EmpName, FROM DBO.EmpInfo;  While specifying the Database name we have use Dbo.[DbName] .  This will prevent any of the underlying tables from being altered without the view being dropped.
  • 28.
  • 29.  This option encrypts the definition.  This option encrypts the definition of the view.  Users will not be able to see the definition of theView after it is created.  This is the main adavatages of view where we can make it secure.  Note: Once view is encrypted, there is no way to decrypt it again. CREATEVIEW DemoView With ENCRYPTION Select ename,edesig from dbo.EmpInfo