Catalog and Metadata
AngaraBase stores metadata for all database objects in a central registry — the SysCatalog. For users, access to metadata is provided via the sys.* system views and introspection functions.
Object Hierarchy
Database objects are organized in a strict hierarchy:
Instance → Database → Schema → Table → Column
Each level has a unique identifier in the SysCatalog. Tables belong to schemas, schemas to databases, and databases to the instance.
SysCatalog
SysCatalog is the central metadata registry. It stores information about:
- tables, columns, and their data types
- indexes and constraints
- users, roles, and privileges
- functions and aggregates
- security policies (RLS)
- statistics for the query optimizer
The SysCatalog is updated during DDL operations (CREATE, ALTER, DROP) and when statistics are gathered.
System Views (sys.*)
System views are read-only and do not require special privileges (with the exception of security-related views).
Instance Identification and State
| View | Description |
|---|---|
sys.identity | Instance identity: version, instance_id |
sys.health | Server health status |
sys.settings | Effective configuration (name, value). Secrets are not exposed |
Data Structure
| View | Description |
|---|---|
sys.tables | All tables with metadata (schema, name, type, row count) |
sys.columns | Columns for each table: column_name, data_type, nullable, etc. |
Statistics
| View | Description |
|---|---|
sys.table_stats | Table-level statistics: stats_level_max, last_committed_rowid, mutation epochs |
sys.column_stats | Column-level statistics: ndv_approx, min/max, null_count, histograms, MCV |
Security and Access
| View | Description |
|---|---|
sys.users | User accounts |
sys.roles | Roles |
sys.user_roles | Assignments of users to roles |
sys.role_privileges | Role privileges |
sys.object_grants | Object-level grants |
sys.my_privileges | Current user’s privileges |
sys.security_policies | RLS policies |
sys.audit_log | Audit log |
Introspection Functions
AngaraBase provides a set of built-in functions for programmatic access to metadata.
Roles and Privileges
| Function | Purpose |
|---|---|
angara_user_roles() | Current user’s roles |
angara_role_privileges() | Privileges of a given role |
angara_user_privileges() | Effective user privileges |
angara_object_privileges() | Privileges on a specific object |
angara_has_privilege() | Check for a specific privilege |
Security (RLS, audit, break-glass)
| Function | Purpose |
|---|---|
angara_table_policies() | RLS policies for a table |
angara_is_rls_active() | Whether RLS is active for a table |
angara_effective_rls_predicate() | The final RLS predicate for the current user |
angara_break_glass_status() | Status of the break-glass session |
angara_audit_verify_chain() | Verify the integrity of the audit chain |
Diagnostics and Performance
| Function / View | Purpose |
|---|---|
angara_stat_activity | Active sessions and running queries |
angara_stat_statements | Aggregated statistics for executed queries |
angara_top_queries() | Top queries by resource consumption |
angara_stat_statements_reset() | Reset query statistics |
Practical Examples
Instance Information
SELECT * FROM sys.identity;
Checking Server Health
SELECT * FROM sys.health;
List All Tables
SELECT * FROM sys.tables;
Checking Security Settings
SELECT name, value FROM sys.settings WHERE name LIKE 'security.%';
Viewing Table Column Statistics
SELECT column_name, ndv_approx, null_count
FROM sys.column_stats
WHERE table_name = 'orders';
Checking Current User Privileges
SELECT * FROM sys.my_privileges;
SELECT angara_has_privilege('orders', 'SELECT');
Related Sections
- Quickstart (sys.* examples) — first steps with system views
- Security — security introspection functions
- Diagnostics — monitoring and troubleshooting
- Query Processing — how the optimizer uses catalog metadata