DISCARD โ discard session state
| Use Case | Command | Description |
|---|---|---|
| ๐ Reset all session state | DISCARD ALL | Releases all temporary resources and resets session to initial state |
| ๐บ๏ธ Clear cached query plans | DISCARD PLANS | Forces reโplanning for prepared statements |
| ๐ข Reset sequence caches | DISCARD SEQUENCES | Clears currval/lastval and preallocated sequence values |
| ๐๏ธ Drop temporary tables | DISCARD TEMPORARY (or TEMP) | Drops all temp tables created 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 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.
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 01:24 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format