Back to all posts

Table Types Comparison: SQL Server vs PostgreSQL

Table Type SQL Server PostgreSQL Scope / Lifetime Usage Notes Permanent Table CREATE TABLE Employee (...) CREATE TABLE Employee (...) Permanent in DB until…

Table TypeSQL ServerPostgreSQLScope / LifetimeUsage Notes
Permanent TableCREATE TABLE Employee (...)CREATE TABLE Employee (...)Permanent in DB until droppedUsed for regular data storage
Local Temporary TableCREATE TABLE #Employee (...)CREATE TEMP TABLE Employee (...)Session-local; auto dropped on disconnectUsed for session-specific temporary data
Global Temp TableCREATE TABLE ##Employee (...)Not supportedAvailable to all sessions until last disconnectShared temp data between sessions
Table VariableDECLARE @Employee TABLE (...)Not supportedLocal to batch or procedureLightweight table variable for procedural code
Common Table Expression (CTE)N/A (but SQL Server supports it too)WITH Employee AS (VALUES (...))Inline, read-only during a single queryQuick temporary inline data set for queries
Unlogged TableN/ACREATE UNLOGGED TABLE Employee (...)Like permanent but faster, not WAL loggedFor fast temp storage with risk of data loss

Keep building your data skillset

Explore more SQL, Python, analytics, and engineering tutorials.