DISCARD(7) PostgreSQL 14.23 Documentation DISCARD(7)
DISCARD - discard session state
| Use Case | Command | Description |
|---|---|---|
| Discard all session state | DISCARD ALL | Releases all temporary resources and resets session to initial state. |
| Discard cached query plans | DISCARD PLANS | Releases all cached query plans, forcing re-planning. |
| Discard sequence cache | DISCARD SEQUENCES | Discards cached sequence-related state and preallocated values. |
| Drop temporary tables | DISCARD TEMPORARY or DISCARD TEMP | Drops all temporary tables in the current session. |
DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }
DISCARD releases internal resources associated with a database session. This command is useful for partially or fully resetting the session's state. There are several subcommands to release different types of resources; the DISCARD ALL variant subsumes all the others, and also resets additional state.
Releases all cached query plans, forcing re-planning to occur the next time the associated prepared statement is used.
Discards all cached sequence-related state, including currval()/lastval() information and any preallocated sequence values that have not yet been returned by nextval(). (See CREATE SEQUENCE (CREATE_SEQUENCE(7)) for a description of preallocated sequence values.)
Drops all temporary tables created in the current session.
Releases all temporary resources associated with the current session and resets the session to its initial state. Currently, this has the same effect as executing the following sequence of statements:
CLOSE ALL;
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD TEMP;
DISCARD SEQUENCES;
DISCARD ALL cannot be executed inside a transaction block.
DISCARD is a PostgreSQL extension.
PostgreSQL 14.23 2026 DISCARD(7)
Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-22 03:28 @2600:1f28:365:80b0:8802:8bb4:3873:328e
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format