presto-docs/src/main/sphinx/sql/prepare.rst
.. code-block:: none
PREPARE statement_name FROM statement
Prepares a statement for execution at a later time. Prepared statements are queries that are saved in a session with a given name. The statement can include parameters in place of literals to be replaced at execution time. Parameters are represented by question marks.
Note: If a query that includes PREPARE returns an error similar to the following:
.. code-block:: none
Request Header Fields Too Large
see :ref:troubleshoot/query:\`Request Header Fields Too Large```.
Prepare a select query::
PREPARE my_select1 FROM
SELECT * FROM nation;
Prepare a select query that includes parameters. The values to compare with
regionkey and nationkey will be filled in with the :doc:execute statement::
PREPARE my_select2 FROM
SELECT name FROM nation WHERE regionkey = ? AND nationkey < ?;
Prepare an insert query::
PREPARE my_insert FROM
INSERT INTO cities VALUES (1, 'San Francisco');
:doc:execute, :doc:deallocate-prepare, :doc:describe-input, :doc:describe-output