You are on page 1of 3

VIEWS

VIEWS

HOW TO MODIFY THE VIRE HOW TO DROP VIEW usage or advantage

‫هنا بكتب اسماء االعمدة اللى‬.] CREATE OR REPLACE VIEW view_name DROP VIEW view_name 1- restriction to data access 2- MAKE COMPLEX QUERIES EASY 3-PROVIDE DATA 4-PRESENT DIFFRENT VIEWS OF
  INDEPENDENCE THE DATA
‫ للجدول على بعضه‬PRIVILEGE ‫ بتعمل‬DCL ‫عشان ال‬

‫عشان بجزء الجداول الى اجزاء صغير و ابص‬ ‫ بيبص لجدول الموظفين غير المدير‬HR ‫يعنى ال‬
Views can be used as security VIEW ‫عليها من خالل ال‬ ‫وهكذا‬
mechanisms by letting users access
data through the view, without
granting the users permissions to
directly access the underlying base VIEWS ‫انواع ال‬
tables of the view.

‫ دى فيو‬COMPLEX VIEWS ‫بالنسبة لل‬ MICROSOFT TYPES


‫انا ممكن استخدمه لتغير ميعن فى اعمدة معينة فى الداتا مش الزم ادى الشخص‬ ... ‫بتبقى االعمدة اللى فيها مش حقيقية‬
FULL PRIVILEGE TO ACCESS THE TABLE ‫اللى هيغير دة‬  
‫ ياثر انه لو جيت اعمل‬.. ‫طيب دة ياثر علي ايه‬
‫ زى مثال انى اعمل‬DML OPERATION Indexed Views Partitioned Views System Views
‫ ساعتها مش هعرف‬INSERT OR UPDATE An indexed view is a view that has been materialized. This means the view definition has been A partitioned view joins horizontally partitioned data from a set of member tables across one or System views expose catalog metadata. You can use system views to return information about the
computed and the resulting data stored just like a table. You index a view by creating a unique more servers. This makes the data appear as if from one table. A view that joins member tables instance of SQL Server or the objects defined in the instance. For example, you can query the
clustered index on it. Indexed views can dramatically improve the performance of some types on the same instance of SQL Server is a local partitioned view. sys.databases catalog view to return information about the user-defined databases available in the
of queries. Indexed views work best for queries that aggregate many rows. They are not well-suited instance. For more information, see System Views (Transact-SQL)
IBM TYPES for underlying data sets that are frequently updated.
VIEWS
1. VIEWS
1.1. ‫ هى عبارة عن‬DATABASE OBJECT ‫ و هى عبارة عن‬LOGICAL Table ‫ او‬.. ‫ مبنى على جدول او مجموعة جداول‬view ‫ او مجموعة‬views ‫ اخرى طيب يعنى ايه‬logical table ‫ يعنى معندوش داتا خاصة بيه يعنى فهو عبارة عن‬window ‫ بشوف منها الداتا اللى فى جداول اخرى ال‬table ‫ اللى بجيب منها الداتا دى و ابنى عليها ال‬view ‫ اسمها‬base table ‫ ال‬view ‫ دة بيتخزن ك‬select statment ‫فى ال‬meta data

1.1.1. Unless indexed, a view does not exist as a stored set of data values in a database.

Link:
https://docs.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver16

1.2. HOW TO CREATE VIEW

1.2.1. CREATE VIEW [ ‫ لو انا مكتبتش اسماء هنا هينزلهم زى ما هو اسمهم فى الجدول االصلى‬SELECT STATEMENT ‫هنا بكتب اسماء االعمدة اللى عايز اعيد تسميتها اللى عملت لها كويرى فى ال‬.] AS ‫ من هنا هبدا اكتب ال صب كويرى اللى عايز ال فيو يعملها‬SELECT F.Name, L.name >>>> ‫ هنا بكتب االعمدة المختارة‬FROM EMPLYE ,PROJEC, WORKS ON >>>>‫ هنا بكتب الجداول اللى هاخد منها االعمدة اللى فوق‬WHERE SSN=ESSN AND C1.T1=C2.T2 >>>JOIN CONDITION
‫ هنا بكتب الجداول اللى باخد منها االعمدة اللى فوق و هنا لو حطيت اكتر من جدول بحط ال‬WITH CHECK OPTION >>> DML ‫ محقق لما اجى اعمل اى‬WHERE CONDITION ‫بستخدمه انه بتحقق ان ال‬
1.3. HOW TO MODIFY THE VIRE

1.3.1. CREATE OR REPLACE VIEW view_name

1.4. HOW TO DROP VIEW

1.4.1. DROP VIEW view_name

1.5. usage or advantage

1.5.1. 1- restriction to data access ‫ للجدول على بعضه‬PRIVILEGE ‫ بتعمل‬DCL ‫عشان ال‬

1.5.1.1. Views can be used as security mechanisms by letting users access data through the view, without granting the users permissions to directly access the underlying base tables of the view.

1.5.1.1.1. ‫ انا ممكن استخدمه لتغير ميعن فى اعمدة معينة فى الداتا مش الزم ادى الشخص اللى هيغير دة‬FULL PRIVILEGE TO ACCESS THE TABLE

1.5.2. 2- MAKE COMPLEX QUERIES EASY

1.5.3. 3-PROVIDE DATA INDEPENDENCE

1.5.3.1. ‫ عشان بجزء الجداول الى اجزاء صغير و ابص عليها من خالل ال‬VIEW

1.5.4. 4-PRESENT DIFFRENT VIEWS OF THE DATA

1.5.4.1. ‫ يعنى ال‬HR ‫بيبص لجدول الموظفين غير المدير وهكذا‬

1.6. ‫ انواع ال‬VIEWS

1.6.1. ‫ بالنسبة لل‬COMPLEX VIEWS ‫ ياثر انه لو جيت اعمل‬.. ‫ طيب دة ياثر علي ايه‬... ‫ دى فيو بتبقى االعمدة اللى فيها مش حقيقية‬DML OPERATION ‫ زى مثال انى اعمل‬INSERT OR UPDATE ‫ساعتها مش هعرف‬

1.6.2. IBM TYPES

1.6.3. MICROSOFT TYPES

1.6.3.1. Indexed Views An indexed view is a view that has been materialized. This means the view definition has been computed and the resulting data stored just like a table. You index a view by creating a unique clustered index on it. Indexed views can dramatically improve the performance of some types of queries. Indexed views work best for queries that aggregate many rows. They are not well-suited for underlying data sets that are frequently updated.

1.6.3.2. Partitioned Views A partitioned view joins horizontally partitioned data from a set of member tables across one or more servers. This makes the data appear as if from one table. A view that joins member tables on the same instance of SQL Server is a local partitioned view.

1.6.3.3. System Views System views expose catalog metadata. You can use system views to return information about the instance of SQL Server or the objects defined in the instance. For example, you can query the sys.databases catalog view to return information about the user-defined databases available in the instance. For more information, see System Views (Transact-SQL)

You might also like