urQL/docs/02-ddl-database.md

91 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2024-01-22 00:50:35 +03:00
# DDL: Database
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
## CREATE DATABASE
Creates a new user-space database on the ship.
2023-12-06 20:38:31 +03:00
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
<create-database> ::=
2024-01-06 21:15:32 +03:00
CREATE DATABASE <database> [ <as-of-time> ]
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### API
2024-04-28 19:22:56 +03:00
```
2024-01-22 00:50:35 +03:00
+$ create-database
$:
%create-database
name=@tas
as-of=(unit <as-of>)
==
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Arguments
2023-12-06 20:38:31 +03:00
**`<database>`**
2024-09-04 18:06:36 +03:00
The user-defined name for the new database. It must comply with the Hoon term naming standard.
2023-12-06 20:38:31 +03:00
2024-01-06 21:15:32 +03:00
**`<as-of-time>`**
2024-01-22 00:50:35 +03:00
Timestamp of database creation. Defaults to `NOW` (current time). Subsequent DDL and data actions must have timestamps greater than this timestamp.
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Remarks
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
This command mutates the state of the Obelisk agent. It inserts a row into the view `sys.sys.databases`.
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Produced Metadata
2023-12-06 20:38:31 +03:00
2024-07-22 18:33:07 +03:00
Schema timestamp
Content timestamp
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Exceptions
2023-12-06 20:38:31 +03:00
2024-08-09 01:25:05 +03:00
database must be created by local agent
2024-01-22 00:50:35 +03:00
database name cannot be 'sys'
2024-08-07 17:00:33 +03:00
database `<database>` already exists'
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Example
2024-04-28 19:22:56 +03:00
```
2024-01-22 00:50:35 +03:00
CREATE DATABASE my-database
2024-04-28 19:22:56 +03:00
```
2024-01-22 00:50:35 +03:00
## DROP DATABASE
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
*supported in urQL parser, not yet supported in Obelisk*
2023-12-06 20:38:31 +03:00
Deletes an existing `<database>` and all associated objects.
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
<drop-database> ::= DROP DATABASE [ FORCE ] <database>
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### API
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
+$ drop-database
$:
%drop-database
name=@tas
force=?
==
2024-04-28 19:22:56 +03:00
```
2023-12-06 20:38:31 +03:00
2024-01-22 00:50:35 +03:00
### Arguments
2023-12-06 20:38:31 +03:00
**`FORCE`**
Optionally, force deletion of a database.
**`<database>`**
The name of the database to delete.
## Remarks
This command mutates the state of the Obelisk agent.
2024-01-22 00:50:35 +03:00
The command only succeeds when no populated tables exist in the database, unless `FORCE` is specified. It removes the row from the view `sys.sys.databases`.
2023-12-06 20:38:31 +03:00
## Produced Metadata
2024-07-22 18:33:07 +03:00
Schema timestamp
Content timestamp
2023-12-06 20:38:31 +03:00
## Exceptions
2024-08-09 01:25:05 +03:00
database must be dropped by local agent
2024-09-04 18:06:36 +03:00
database %sys cannot be dropped
2024-08-07 17:00:33 +03:00
database `<database>` does not exist
`<database>` has populated tables and `FORCE` was not specified
state change after query in script