2023-01-05 21:25:45 +03:00
# DROP DATABASE
2023-05-25 05:33:27 +03:00
Deletes an existing `<database>` and all associated objects.
```
< drop-database > ::= DROP DATABASE [ FORCE ] < database >
```
2023-05-23 00:08:37 +03:00
## API
```
+$ drop-database
$:
%drop-database
name=@tas
force=?
==
```
## Arguments
2023-05-25 05:33:27 +03:00
**`FORCE`**
Optionally, force deletion of a database.
**`< database > `**
The name of the database to delete.
2023-05-23 00:08:37 +03:00
## Remarks
2023-05-25 05:33:27 +03:00
This command mutates the state of the Obelisk agent.
2023-05-23 00:08:37 +03:00
2023-05-25 05:33:27 +03:00
The command only succeeds when no populated tables exist in the database, unless `FORCE` is specified.
2023-05-23 00:08:37 +03:00
## Produced Metadata
2023-05-25 05:33:27 +03:00
DELETE row from `sys.sys.databases` .
2023-05-23 00:08:37 +03:00
## Exceptions
2023-05-25 05:33:27 +03:00
`<database>` does not exist.
`<database>` has populated tables and FORCE was not specified.
2022-08-06 17:06:18 +03:00
2023-01-05 21:25:45 +03:00
# DROP INDEX
2023-05-25 05:33:27 +03:00
Deletes an existing `<index>` .
2022-08-06 17:06:18 +03:00
2022-08-10 23:23:12 +03:00
```
2023-05-25 05:33:27 +03:00
< drop-index > ::=
DROP INDEX < index >
ON [ < db-qualifer > ] { < table > | < view > }
2022-08-10 23:23:12 +03:00
```
2022-08-10 21:45:17 +03:00
2023-05-23 00:08:37 +03:00
## API
```
+$ drop-index
$:
%drop-index
name=@tas
object=qualified-object
==
```
## Arguments
2023-05-25 05:33:27 +03:00
**`< index > `**
The name of the index to delete.
**`< table > | < view > `**
`<table>` or `<view>` with the named index.
2023-05-23 00:08:37 +03:00
## Remarks
2023-05-25 05:33:27 +03:00
This command mutates the state of the Obelisk agent.
Indexes with names that begin with "pk-" cannot be dropped, as these are table primary keys.
2023-05-23 00:08:37 +03:00
2023-05-25 05:33:27 +03:00
This command can be used to delete a `<foreign-key>` .
2023-05-23 00:08:37 +03:00
2023-05-25 05:33:27 +03:00
If `<view>` is shadowing `<table>` , the system attempts to find `<index>` on `<view>` first, then `<table>` .
2023-05-23 00:08:37 +03:00
## Produced Metadata
2023-05-25 05:33:27 +03:00
DELETE FROM `<database>.sys.indices`
DELETE FROM `<database>.sys.table-ref-integrity`
2023-05-23 00:08:37 +03:00
## Exceptions
2023-05-25 05:33:27 +03:00
`<table>` or `<view>` does not exist
`<index>` does not exist on `<table>` or `<view>` .
2022-08-10 21:45:17 +03:00
2023-01-05 21:25:45 +03:00
# DROP NAMESPACE
2023-05-25 05:33:27 +03:00
Deletes a `<namespace>` and all its associated objects.
2022-08-10 21:45:17 +03:00
2023-05-25 05:33:27 +03:00
```
< drop-namespace > ::=
DROP NAMESPACE [ FORCE ] [ < database > . ]< namespace >
```
2023-05-23 00:08:37 +03:00
## API
```
+$ drop-namespace
$:
%drop-namespace
database-name=@tas
name=@tas
force=?
==
```
## Arguments
2023-05-25 05:33:27 +03:00
**`FORCE`**
Optionally, force deletion of `<namespace>` .
**`< namespace > `**
The name of `<namespace>` to delete.
2023-05-23 00:08:37 +03:00
## Remarks
2023-05-25 05:33:27 +03:00
This command mutates the state of the Obelisk agent.
2023-05-23 00:08:37 +03:00
2023-05-25 05:33:27 +03:00
Only succeeds when no *populated* `<table>` s are in the namespace, unless `FORCE` is specified, possibly resulting in cascading object drops described in `DROP TABLE` .
2022-08-14 04:30:15 +03:00
2023-05-25 05:33:27 +03:00
The namespaces *dbo* and *sys* cannot be dropped.
2022-08-06 17:06:18 +03:00
2023-05-23 00:08:37 +03:00
## Produced Metadata
2023-05-25 05:33:27 +03:00
DELETE row from `<database>.sys.namespaces` .
2023-05-23 00:08:37 +03:00
## Exceptions
2023-05-25 05:33:27 +03:00
`<namespace>` does not exist.
`<namespace>` has populated tables and FORCE was not specified.
2023-05-23 00:08:37 +03:00
2022-08-06 17:06:18 +03:00
2023-01-05 21:25:45 +03:00
# DROP TABLE
2023-05-25 05:33:27 +03:00
Deletes a `<table>` and all associated objects
2022-08-06 17:06:18 +03:00
2023-05-25 05:33:27 +03:00
```
< drop-table > ::= DROP TABLE [ FORCE ] [ < db-qualifer > ]{ < table > }
```
2023-05-23 00:08:37 +03:00
## API
```
+$ drop-table
$:
%drop-table
table=qualified-object
force=?
==
```
## Arguments
2023-05-25 05:33:27 +03:00
**`FORCE`**
Optionally, force deletion of a table.
**`< table > `**
Name of `<table>` to delete.
2023-05-23 00:08:37 +03:00
## Remarks
2023-05-25 05:33:27 +03:00
This command mutates the state of the Obelisk agent.
2023-05-23 00:08:37 +03:00
2023-01-05 21:25:45 +03:00
Cannot drop if used in a view or foreign key, unless `FORCE` is specified, resulting in cascading object drops.
2022-08-06 17:06:18 +03:00
2023-05-25 05:33:27 +03:00
Cannot drop when the `<table>` is populated unless `FORCE` is specified.
2023-05-23 00:08:37 +03:00
## Produced Metadata
2023-05-25 05:33:27 +03:00
DELETE from `<database>.sys.tables` .
DELETE from `<database>.sys.views` .
DELETE from `<database>.sys.indices` .
2023-05-23 00:08:37 +03:00
## Exceptions
2023-05-25 05:33:27 +03:00
`<table>` does not exist.
`<table>` is populated and FORCE was not specified.
`<table>` used in `<view>` and FORCE was not specified.
`<table>` used in `<foreign-key>` and FORCE was not specified.
2022-08-06 17:06:18 +03:00
2023-01-05 21:25:45 +03:00
# DROP TRIGGER
2022-08-06 17:06:18 +03:00
2023-05-23 00:08:37 +03:00
TBD
2022-08-10 23:23:12 +03:00
```
2023-05-25 05:33:27 +03:00
< drop-trigger > ::=
DROP TRIGGER [ < db-qualifer > ]{ < trigger > }
ON { < table > | < view > }
2022-08-10 23:23:12 +03:00
```
2022-08-06 17:06:18 +03:00
2022-08-10 21:45:17 +03:00
2023-01-05 21:25:45 +03:00
# DROP TYPE
2022-08-06 17:06:18 +03:00
2022-08-10 21:45:17 +03:00
TBD
2023-05-25 05:33:27 +03:00
`DROP TYPE <type>`
2023-05-23 00:08:37 +03:00
## Remarks
2022-08-10 21:45:17 +03:00
Cannot drop if type-name is in use.
2022-08-06 17:06:18 +03:00
2023-01-05 21:25:45 +03:00
# DROP VIEW
2022-08-06 17:06:18 +03:00
2023-05-25 05:33:27 +03:00
```
< drop-view > ::= DROP VIEW [ FORCE ] [ < db-qualifer > ]< view >
```
2022-08-06 17:06:18 +03:00
2023-05-23 00:08:37 +03:00
## API
```
+$ drop-view
$:
%drop-view
view=qualified-object
force=?
==
```
## Arguments
2023-05-25 05:33:27 +03:00
**`FORCE`**
Force delete of `<view>` .
**`< view > `**
Name of `<view>` to delete.
2023-05-23 00:08:37 +03:00
## Remarks
2023-05-25 05:33:27 +03:00
This command mutates the state of the Obelisk agent.
2023-05-23 00:08:37 +03:00
2023-05-25 05:33:27 +03:00
Views that are in use in another view cannot be dropped unless `FORCE` is specified, which may result in cascading object drops.
2023-05-23 00:08:37 +03:00
## Produced Metadata
2023-05-25 05:33:27 +03:00
DELETE from `<database>.sys.views` .
2023-05-23 00:08:37 +03:00
## Exceptions
2023-05-25 05:33:27 +03:00
`<view>` does not exist.
`<view>` is in use by other `<view>` and FORCE was not specified.