grant and revoke commands that maintain privileges even when tables or functions are dropped and recreated. This is essential for streaming data platforms where schema changes are common.
How Metadb Access Control Works
Metadb’s access control differs from standard SQL grants:Persistent Privileges
Privileges remain valid even if objects are dropped and recreated
Metadb-Managed Objects
Works with tables and functions managed by Metadb
User Registration Required
Only registered users can receive Metadb access grants
Granular or Broad
Grant access to specific objects or all Metadb-managed data
Metadb-Managed Objects
These commands work with:- System tables:
metadb.table_update,metadb.log,metadb.base_table - System functions:
mdblog(),mdbversion(),mdbusers(),ps() - Main and current tables: Tables streamed from data sources
- Transformed tables: Tables created from JSON or other transformations
- External SQL tables: Tables created by automated execution of external SQL
Grant Access
Enable access to Metadb-managed tables and functions.Syntax
Parameters
An existing Metadb-managed table (schema-qualified name).
An existing Metadb-managed function.
Grants access to all current and future Metadb-managed objects.
An existing registered user to be granted access.
Examples
Grant Access to a Single Table
Grant Access to a Function
Grant Access to Everything
Grant Limited Access Only
To grant a user access to only specific tables and nothing else:Revoke Access
Remove access privileges from a user.Syntax
Parameters
An existing Metadb-managed table.
An existing Metadb-managed function.
Revokes access to all Metadb-managed objects.
An existing user that will have access removed.
Examples
Revoke Access to a Single Table
Revoke All Access
Revoke Function Access
Access Control Patterns
- Read-Only User
- Administrator
- Department Access
- Temporary Access
Create a user with access to specific tables:
Best Practices
Principle of Least Privilege
Principle of Least Privilege
Grant users only the minimum access they need. Start with specific table grants rather than
grant access on all.Document Access Grants
Document Access Grants
Keep a record of why each user has been granted specific access. Use the
comment option when creating users to document their role.Regular Access Reviews
Regular Access Reviews
Periodically review user access and revoke unnecessary privileges. Users’ roles change over time.
Use Groups for Common Patterns
Use Groups for Common Patterns
If you have multiple users needing the same access, consider creating a role pattern you can replicate:
Checking User Access
To see what access a user has, you can query their privileges using PostgreSQL system catalogs:Relationship with User Management
Registration Required: Users must be registered with Metadb before they can receive access grants. Use
create user or register user first.Automatic Deregistration: When you use
deregister user, it automatically executes revoke access on all and prevents future grants.See Also
User Management
Create and manage database users
Data Sources
Configure data sources and tables
