Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
o Virtual relation that does not actually exist in the CREATE VIEW view_name [ (column_name [,...]) ]
database but is produced upon request, at time of AS subselect
request.
..
o SQL-92 imposes several restrictions on creation and o For example, following query would fail:
use of views. SELECT COUNT(cnt)
FROM staff_prop_cnt;
(a) If column in view is based on an aggregate function:
o Similarly, following query would also fail:
– Column may appear only in SELECT and ORDER
BY clauses of queries that access view. SELECT *
FROM staff_prop_cnt
– Column may not be used in WHERE nor be an WHERE cnt > 2;
argument to an aggregate function in any query
based on view.
(b) Grouped view may never be joined with a base o Consider view Staff_Prop_Cnt:
table or a view.
CREATE VIEW staff_prop_cnt (branch_no,
o For example, Staff_Prop_Cnt view is a grouped staff_no, cnt)
view, so any attempt to join this view with another AS SELECT s.bno, s.sno, COUNT(*)
table or view fails.
FROM staff s, property_for_rent p
WHERE s.sno = p.sno
GROUP BY s.bno, s.sno;
o Also, every row added through view must not o Enterprise constraints
violate integrity constraints of base table.
CASCADE: Delete row from parent and delete FOREIGN KEY (sno) REFERENCES staff
matching rows in child, and so on in cascading ON DELETE SET NULL
manner.
FOREIGN KEY (ono) REFERENCES owner
SET NULL: Delete row from parent and set FK ON UPDATE CASCADE
column(s) in child to NULL. Only valid if FK columns
are NOT NULL.
Give Manager full privileges to Staff table. Give Admin SELECT and UPDATE on column Salary
of Staff.
GRANT ALL PRIVILEGES
ON staff GRANT SELECT, UPDATE (salary)
TO manager WITH GRANT OPTION; ON staff
TO admin;
Example 7 - GRANT Specific Privileges to Multiple Users Example 8 - GRANT Specific Privileges to PUBLIC
Give users Personnel and Deputy SELECT on Staff Give all users SELECT on Branch table.
table.
GRANT SELECT
GRANT SELECT ON branch
ON staff TO PUBLIC;
TO personnel, deputy;
Revoke privilege SELECT on Branch table from all Revoke all privileges given to Deputy on Staff table.
users.
REVOKE ALL PRIVILEGES
REVOKE SELECT ON staff
ON branch FROM deputy;
FROM PUBLIC ;