2020-07-11 11:05:49 +00:00
---
2022-08-28 14:53:34 +00:00
slug: /en/sql-reference/statements/drop
2022-04-09 13:29:05 +00:00
sidebar_position: 44
sidebar_label: DROP
2020-07-11 11:05:49 +00:00
---
2022-06-02 10:55:18 +00:00
# DROP Statements
2020-07-11 11:05:49 +00:00
2022-09-08 13:21:59 +00:00
Deletes existing entity. If the `IF EXISTS` clause is specified, these queries do not return an error if the entity does not exist. If the `SYNC` modifier is specified, the entity is dropped without delay.
2020-07-11 11:05:49 +00:00
2022-06-02 10:55:18 +00:00
## DROP DATABASE
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes all tables inside the `db` database, then deletes the `db` database itself.
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2022-09-08 13:21:59 +00:00
DROP DATABASE [IF EXISTS] db [ON CLUSTER cluster] [SYNC]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP TABLE
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes the table.
2023-04-05 14:49:03 +00:00
:::tip
Also see [UNDROP TABLE ](/docs/en/sql-reference/statements/undrop.md )
:::
2020-10-26 10:09:41 +00:00
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2022-09-08 13:21:59 +00:00
DROP [TEMPORARY] TABLE [IF EXISTS] [db.]name [ON CLUSTER cluster] [SYNC]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP DICTIONARY
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes the dictionary.
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2022-09-08 13:21:59 +00:00
DROP DICTIONARY [IF EXISTS] [db.]name [SYNC]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP USER
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a user.
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2023-07-28 03:37:09 +00:00
DROP USER [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage_type]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP ROLE
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a role. The deleted role is revoked from all the entities where it was assigned.
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2023-07-28 03:37:09 +00:00
DROP ROLE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage_type]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP ROW POLICY
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a row policy. Deleted row policy is revoked from all the entities where it was assigned.
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2023-07-28 03:37:09 +00:00
DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] [FROM access_storage_type]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP QUOTA
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a quota. The deleted quota is revoked from all the entities where it was assigned.
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2023-07-28 03:37:09 +00:00
DROP QUOTA [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage_type]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP SETTINGS PROFILE
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a settings profile. The deleted settings profile is revoked from all the entities where it was assigned.
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Syntax:
2020-07-11 11:05:49 +00:00
``` sql
2023-07-28 03:37:09 +00:00
DROP [SETTINGS] PROFILE [IF EXISTS] name [,...] [ON CLUSTER cluster_name] [FROM access_storage_type]
2020-07-11 11:05:49 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP VIEW
2020-07-11 11:05:49 +00:00
2020-10-26 10:09:41 +00:00
Deletes a view. Views can be deleted by a `DROP TABLE` command as well but `DROP VIEW` checks that `[db.]name` is a view.
2020-07-21 19:24:08 +00:00
2020-10-26 10:09:41 +00:00
Syntax:
2020-07-21 19:24:08 +00:00
``` sql
2022-09-08 13:21:59 +00:00
DROP VIEW [IF EXISTS] [db.]name [ON CLUSTER cluster] [SYNC]
2020-07-21 19:24:08 +00:00
```
2022-06-02 10:55:18 +00:00
## DROP FUNCTION
2021-08-21 12:38:19 +00:00
Deletes a user defined function created by [CREATE FUNCTION ](./create/function.md ).
System functions can not be dropped.
**Syntax**
``` sql
2022-07-04 11:34:26 +00:00
DROP FUNCTION [IF EXISTS] function_name [on CLUSTER cluster]
2021-08-21 12:38:19 +00:00
```
**Example**
``` sql
2021-08-22 19:57:59 +00:00
CREATE FUNCTION linear_equation AS (x, k, b) -> k*x + b;
DROP FUNCTION linear_equation;
2021-08-21 12:38:19 +00:00
```
2023-07-27 06:42:38 +00:00
## DROP NAMED COLLECTION
Deletes a named collection.
**Syntax**
``` sql
DROP NAMED COLLECTION [IF EXISTS] name [on CLUSTER cluster]
```
**Example**
``` sql
CREATE NAMED COLLECTION foobar AS a = '1', b = '2';
DROP NAMED COLLECTION foobar;
```