IT-lexikon › Databas › Temporary table

Temporary table

Databas In English → Uppdaterad: 2026-05-28

Session-scoped table — existerar bara för current session/connection, droppas auto vid disconnect. CREATE TEMP TABLE staging AS SELECT .... Use case: complex multi-step queries, ETL-staging, computation-caching inom session.

PostgreSQL: temp tables i pg_temp_session-schema. MySQL: TEMPORARY-keyword. SQL Server: # eller ## prefix (local vs global temp). Performance: typiskt i RAM (PostgreSQL temp_buffers-tunable), no WAL-overhead (since session-scoped). Index allowed. Schema-name conflict: temp + real with same name → temp wins. Connection pooling-fälla: PgBouncer transaction-mode bryter temp-tables (varje statement annan connection). Modern alternative: WITH (CTE) + LATERAL för in-query-staging utan persistens.

← Tillbaka till lexikonet