BEGIN
Enterprise command reference.
Command Snapshot
| Field | Value |
|---|---|
| Category | Session and Transaction Control |
| Mutates Data | Yes/Depends |
| Scope | Session / Transaction |
| Privilege Model | Session-scoped variants require session rights; global variants require administrative privilege. |
Purpose
Executes the BEGIN SQL command with MonkDB distributed runtime semantics.
Syntax
BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]
Operational Notes
- Use schema-qualified identifiers in automation and automation pipelines.
- Validate behavior in staging for cluster-impacting or governance-impacting changes.
- Confirm runtime effects through system tables and metrics before and after execution.
When to Use
- Use to control session behavior, cursors, or transaction compatibility settings.
- Use when client compatibility or session-scoped runtime behavior must be explicit.
When Not to Use
- Avoid relying on PostgreSQL-compatible clauses whose behavior is intentionally no-op in MonkDB.
Common Errors and Troubleshooting
| Symptom | Likely Cause | Action |
|---|---|---|
| Permission denied / unauthorized | Missing privilege on object or cluster scope | Re-run with required grants or elevated admin role. |
| Analysis/parse error | Syntax variant or object shape mismatch | Compare with canonical syntax and object definition. |
| Runtime failure under load | Resource limits, breaker pressure, or node state transitions | Check sys.jobs, sys.operations, sys.checks, and retry after mitigation. |
Cross-References
Detailed Reference
The BEGIN statement in MonkDB is recognized for compatibility with PostgreSQL clients but does not initiate actual transactions, as MonkDB does not support transactional operations.
SQL Statement
BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]
Where transaction_mode can include:
ISOLATION LEVEL isolation_levelREAD WRITEorREAD ONLY[NOT] DEFERRABLE
And isolation_level options are:
SERIALIZABLEREPEATABLE READREAD COMMITTEDREAD UNCOMMITTED
Description
-
Purpose: In MonkDB, the
BEGINstatement does not initiate a transaction. Its primary function is to define a scope for declaring cursors without theHOLDoption. -
Behavior:
- Cursors declared without
HOLDare automatically closed upon execution of anENDorCOMMITcommand. - Nested
BEGINstatements are not supported; eachBEGINstarts a new scope, regardless of previousBEGINexecutions.
Parameters
-
WORK|TRANSACTION: Optional keywords included for compatibility; they have no operational effect in MonkDB. -
transaction_mode: Specifies transaction characteristics such as isolation level and access mode. These parameters are accepted for syntax compatibility but do not influence behavior in MonkDB.
Notes
-
Transaction Support: MonkDB does not support traditional transactions. Statements like
BEGIN,START TRANSACTION,COMMIT, andROLLBACKare accepted for compatibility purposes but do not alter database behavior. -
Cursor Management: While transactions are not supported,
BEGINcan be used to establish a scope for cursors without theHOLDoption, which are closed automatically uponENDorCOMMIT.
Permissions
- Execution Rights: Any user with the ability to execute SQL statements can issue the
BEGINcommand. No special permissions are required.
Summary
| Command | Description | Transaction Support | Cursor Scope Management |
|---|---|---|---|
BEGIN |
Starts a scope for cursors without HOLD; does not initiate a transaction. |
No | Yes |
While MonkDB does not support transactions, understanding the role of the BEGIN statement can aid in managing cursor scopes effectively within the database environment.