DETACH DATABASE
The DETACH DATABASE statement removes a previously attached database from the current connection. After detaching, tables in that database are no longer accessible through the schema name.Syntax
Description
DETACH closes the connection to the attached database identified byschema-name and frees its resources. Any subsequent references to schema-name.table-name will fail.
Clauses
| Clause | Description |
|---|---|
DATABASE | Optional keyword. Has no effect on behavior. |
schema-name | The schema name assigned when the database was attached. |
main and temp schemas cannot be detached.
DETACH cannot be used while a transaction is active. Commit or roll back any open transaction before detaching a database.
Examples
Detach a Database
Detach Without the DATABASE Keyword
See Also
- ATTACH DATABASE for attaching a database