Design tables using Synapse SQL in Azure Synapse Analytics
Internal tables store data within Azure Synapse and support Massively Parallel Processing (MPP). These tables are ideal for large-scale data warehousing and analytics. There are three types of internal table distributions:
CREATE TABLE my_table ( id INT, name NVARCHAR(100) ) WITH ( DISTRIBUTION = HASH(id), CLUSTERED COLUMNSTORE INDEX );
Temporary tables are session-specific tables that are automatically deleted when the session ends. They are useful for storing intermediate results or simplifying complex queries. There are two types:
#
, these tables are visible only in the session that created them.##
, these tables are visible to all sessions.CREATE TABLE #temp_table ( id INT, name NVARCHAR(100) );
External tables reference data stored outside of Azure Synapse, such as in Azure Data Lake or Blob Storage. These tables are typically used in serverless SQL pools, allowing you to query large datasets without importing them into Synapse.
CREATE EXTERNAL TABLE external_table ( id INT, name NVARCHAR(100) ) WITH ( DATA_SOURCE = my_data_source, LOCATION = '/path/to/data/', FILE_FORMAT = my_file_format );
Views in Azure Synapse are virtual tables created from the results of a query. They don’t store data themselves but provide a way to simplify query logic. Materialized Views store query results and improve performance for repeated queries.
CREATE VIEW my_view AS SELECT id, name FROM my_table;
By leveraging these types of tables, Azure Synapse allows flexible data storage solutions depending on the specific use case, performance needs, and cost-efficiency considerations.