View with GRANT Permissions
View with GRANT Permissions is a SQL statement in the Views category. Views are commonly used for row/column-level security. Grant access to views instead of base tables. The syntax is GRANT SELECT ON view_name TO user_or_role;. It returns permission view. A typical example: CREATE VIEW employee_public AS SELECT id, name, department FROM employees; -- Excludes sensitive columns: salary, ssn CREATE VIEW dept_managers AS SELECT * FROM employees WHERE job_title = 'Manager'; -- Row-level restriction GRANT SELECT ON employee_public TO readonly_user; GRANT SELECT ON dept_managers TO hr_manager; -- Users only see what the view allows -- Base table employees remains fully protected A close relative is CREATE VIEW, which creates a virtual table based on a SELECT query. Think of it as a saved query that acts like a table. A close relative is DROP VIEW, which removes a view from the database. Does not affect the underlying tables.