> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/commands/data-definition/drop-location",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference and syntax for the DROP LOCATION statement.

# DROP LOCATION

Removes a location object from your Firebolt account. Be cautious when dropping a location that is referenced by external tables, as it may impact dependent objects.

For a comprehensive guide to LOCATION objects, see [LOCATION objects](/guides/security/location).

**Topics:**

* [Syntax](#syntax)
* [Parameters](#parameters)
* [Examples](#examples)
* [Error handling](#error-handling)
* [Best practices](#best-practices)
* [Notes](#notes)

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
DROP LOCATION [IF EXISTS] <location_name> [WITH FORCE]
```

## Parameters

| Parameter         | Description                                                                                                                                      |
| :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------- |
| `<location_name>` | The identifier of the location to remove.                                                                                                        |
| `IF EXISTS`       | A parameter that suppresses the error if the location doesn't exist.                                                                             |
| `WITH FORCE`      | Forces the removal of the location even if it has dependent external tables. **Warning**: This option invalidates all dependent external tables. |

## Examples

**Drop a location**

The following code example removes a `LOCATION` object from your Firebolt account:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
DROP LOCATION my_location
```

**Drop IF EXISTS**

The following code example removes a `LOCATION` object from your Firebolt account if it exists:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
DROP LOCATION IF EXISTS my_location
```

**Drop with FORCE Option**

If you attempt to drop a location that is referenced by an external table, the drop operation fails by default. You can do either of the following:

1. **Safe Approach**: Drop all dependent external tables before dropping the location.
2. **Force Approach**: Use the `WITH FORCE` option to drop the location immediately regardless of dependencies.

If you choose `WITH FORCE`, the following apply:

* The location is deleted regardless of existing dependencies.
* All external tables that reference the removed location become invalid.
* Queries on any invalid tables will result in an error.
* You must manually clean up the invalid external tables after using `WITH FORCE`.

The following code example deletes a `LOCATION` object from your Firebolt account without considering its dependencies:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
DROP LOCATION my_location WITH FORCE
```

## Error handling

The following table lists the types of errors that may occur during location removal:

| Error Type                             | Cause                                                                                    | Resolution                                                                       |
| :------------------------------------- | :--------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------- |
| **Location Not Found or Unauthorized** | The specified location does not exist or you lack permission to access it.               | Use `IF EXISTS` to handle non-existent locations without error.                  |
| **Dependent Objects Exist**            | The location is referenced by one or more external tables.                               | Drop the dependent tables first or use `WITH FORCE` to bypass dependency checks. |
| **Invalid External Table**             | Attempting to query an external table after its location was removed using `WITH FORCE`. | Drop the invalid external table.                                                 |

## Best Practices

When dropping a location, consider the following:

1. **Before Dropping**
   * Use `IF EXISTS` to handle non-existent locations gracefully.
   * Ensure no active queries are using the location.
   * Check for dependent external tables.

To identify external tables that depend on this location, execute the following query.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT * FROM information_schema.tables WHERE location_name = 'my_location_name'
```

2. **Using WITH FORCE**
   * Use only when necessary.
   * Clean up invalid external tables immediately.
   * Document the reason for using this option.

3. **After Dropping**
   * Verify all dependent objects are handled.
   * Update any scripts or documentation referencing the location.

## Notes

* All identifiers are case-insensitive unless enclosed in double-quotes
* For more information about object identifiers, see [Object identifiers](/reference-sql/lexical-structure/object-identifiers)
