# WAIT and NOWAIT

Extended syntax so that it is possible to set [innodb\_lock\_wait\_timeout](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_lock_wait_timeout) and [lock\_wait\_timeout](/docs/server/server-management/variables-and-modes/server-system-variables.md#lock_wait_timeout) for the following statements:

## Syntax

```sql
ALTER TABLE tbl_name [WAIT n|NOWAIT] ...
CREATE ... INDEX ON tbl_name (index_col_name, ...) [WAIT n|NOWAIT] ...
DROP INDEX ... [WAIT n|NOWAIT]
DROP TABLE tbl_name [WAIT n|NOWAIT] ...
LOCK TABLE ... [WAIT n|NOWAIT]
OPTIMIZE TABLE tbl_name [WAIT n|NOWAIT]
RENAME TABLE tbl_name [WAIT n|NOWAIT] ...
SELECT ... FOR UPDATE [WAIT n|NOWAIT]
SELECT ... LOCK IN SHARE MODE [WAIT n|NOWAIT]
TRUNCATE TABLE tbl_name [WAIT n|NOWAIT]
```

## Description

The lock wait timeout can be explicitly set in the statement by using either `WAIT n` (to set the wait in seconds) or `NOWAIT`, in which case the statement will immediately fail if the lock cannot be obtained. `WAIT 0` is equivalent to `NOWAIT`.

## See Also

* [Query Limits and Timeouts](/docs/server/ha-and-performance/optimization-and-tuning/query-optimizations/query-limits-and-timeouts.md)
* [ALTER TABLE](/docs/server/reference/sql-statements/data-definition/alter/alter-table.md)
* [CREATE INDEX](/docs/server/reference/sql-statements/data-definition/create/create-index.md)
* [DROP INDEX](/docs/server/reference/sql-statements/data-definition/drop/drop-index.md)
* [DROP TABLE](/docs/server/server-usage/tables/drop-table.md)
* [LOCK TABLES and UNLOCK TABLES](/docs/server/reference/sql-statements/transactions/lock-tables.md)
* [OPTIMIZE TABLE](/docs/server/ha-and-performance/optimization-and-tuning/optimizing-tables/optimize-table.md)
* [RENAME TABLE](/docs/server/reference/sql-statements/data-definition/rename-table.md)
* [SELECT](/docs/server/reference/sql-statements/data-manipulation/selecting-data/select.md)
* [TRUNCATE TABLE](/docs/server/reference/sql-statements/table-statements/truncate-table.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/transactions/wait-and-nowait.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
