Access control

SQL GRANT / REVOKE

Manage database privileges; object scope, roles and syntax differ across engines.

Availability: Common SQL with references for SQL standard, MySQL/MariaDB, PostgreSQL, SQL Server, SQLite and Oracle Database; syntax and feature support vary by engine and version.中文

Syntax

GRANT privilege ON object TO principal;
REVOKE privilege ON object FROM principal;

Examples

Manage database privileges; object scope, roles and syntax differ across engines.

GRANT SELECT ON reporting_view TO analyst_role;

SQLite-oriented example; consult the relevant dialect manual.

GRANT SELECT ON reporting_view TO analyst_role;

Parameters, options and clauses

Option / clauseDescription
PrincipalSpecify the user, role or other database principal.
PrivilegeChoose permissions such as SELECT, INSERT, UPDATE or EXECUTE.
ON objectSet the database object or scope to which a privilege applies.
TO / FROMName a grantee for GRANT or a principal for REVOKE.
WITH GRANT OPTIONAllow onward grants where the database supports it.

Dialect references

Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory