Help Center > > Developer Guide> SQL Reference> SQL Syntax> PREPARE

PREPARE

Updated at: May 15, 2019 GMT+08:00

Function

PREPARE creates a prepared statement.

A prepared statement is a performance optimizing object on the server. When the PREPARE statement is executed, the specified query is parsed, analyzed, and rewritten. When the EXECUTE is executed, the prepared statement is planned and executed. This avoids repetitive parsing and analysis. After the PREPARE statement is created, it exists throughout the database session. Once it is created (even if in a transaction block), it will not be deleted when a transaction is rolled back. It can only be deleted by explicitly invoking DEALLOCATE or automatically deleted when the session ends.

Precautions

None

Syntax

PREPARE name [ ( data_type [, ...] ) ] AS statement;

Parameter Description

  • name

    Specifies the name of a prepared statement. It must be unique in the current session.

  • data_type

    Specifies the type of a parameter.

  • statement

    Specifies a SELECT, INSERT, UPDATE, DELETE, or VALUES statement.

Examples

See Examples in EXECUTE.

Helpful Links

DEALLOCATE

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel