# Execute SQL and manage SQL metadata

Execute SQL, track execution status and results, and query or delete related database, table, and view metadata. This page does not manage saved SQL or data dashboards; see [Manage SQL workbooks and data dashboards](https://omnifabric.cloudsigma.com/docs/developer/api/ai-studio/data-processing/sql-workbooks-dashboards.html.md) for those objects.

## Prerequisites

Prepare credentials that can access the target workspace and database information for SQL to execute or objects to query. For service endpoints, authentication, and general request formats, see [Make your first AI Studio API call](https://omnifabric.cloudsigma.com/docs/developer/quickstart/index.html.md).

Before querying or deleting metadata, identify the target object through database and table queries.

## Call sequence

1. To understand existing objects, query databases, tables in a database, table information, table fields, or table-creation statements.
2. After submitting SQL execution, retain the execution ID and query execution status.
3. Query or download results after they become available. Cancel an execution when it no longer needs to continue.
4. Before deleting a database, table, or view, confirm the object and impact scope.

## API operations

### Execute SQL and obtain results

| Task | Use it when |
| --- | --- |
| [Execute SQL](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/execute-sql.html.md) | Submit SQL execution. |
| [Query execution status](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/get-execution-status.html.md) | Check current execution status after submission. |
| [Query execution results](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/get-execution-result.html.md) | Read results after they become available. |
| [Download execution results](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/download-execution-result.html.md) | Obtain an execution-result file. |
| [Cancel an execution](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/cancel-execution.html.md) | The target execution no longer needs to continue. |

### Query SQL metadata

| Task | Use it when |
| --- | --- |
| [Query databases](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/list-databases.html.md) | Select a target database. |
| [Query tables in a database](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/list-database-tables.html.md) | Locate a table in a selected database. |
| [Query table information](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/get-table-info.html.md) | Inspect current information for one table. |
| [View table fields](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/list-table-columns.html.md) | View table fields. |
| [Query a creation statement](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/get-table-ddl.html.md) | View a table-definition statement. |

### Delete metadata objects

| Task | Use it when |
| --- | --- |
| [Delete a database](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/delete-database.html.md) | You confirmed that the database is no longer needed. |
| [Delete a table](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/delete-table.html.md) | You confirmed that the table is no longer needed. |
| [Delete a view](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-metadata/delete-view.html.md) | You confirmed that the view is no longer needed. |

## Confirm the result

After submitting SQL, first use [Get execution status](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-execution/get-execution-status.html.md) to confirm progress, then query or download results. Before and after deleting metadata objects, use the relevant database, table, and table-information queries to confirm the target object.

## Limitations and notes

- Submitting SQL does not mean results are available. Use execution status and result queries to confirm.
- Before deleting a database, table, or view, confirm impact and conditions on the corresponding action page.

## Next steps

- [Manage SQL workbooks and data dashboards](https://omnifabric.cloudsigma.com/docs/developer/api/ai-studio/data-processing/sql-workbooks-dashboards.html.md)
