Tutorial: Create tables in a data warehouse
Applies to: ✅ Warehouse in Microsoft Fabric
Learn how to create tables in the data warehouse you created in a previous part of the tutorial.
Create a table
Select Workspaces in the navigation menu.
Select the workspace created in Tutorial: Create a Microsoft Fabric data workspace, such as Data Warehouse Tutorial.
From the item list, select
WideWorldImporters
with the type of Warehouse.From the ribbon, select New SQL query. Under Blank, select New SQL query for a new blank query window.
In the query editor, paste the following code.
/* 1. Drop the dimension_city table if it already exists. 2. Create the dimension_city table. 3. Drop the fact_sale table if it already exists. 4. Create the fact_sale table. */ --dimension_city DROP TABLE IF EXISTS [dbo].[dimension_city]; CREATE TABLE [dbo].[dimension_city] ( [CityKey] [int] NULL, [WWICityID] [int] NULL, [City] [varchar](8000) NULL, [StateProvince] [varchar](8000) NULL, [Country] [varchar](8000) NULL, [Continent] [varchar](8000) NULL, [SalesTerritory] [varchar](8000) NULL, [Region] [varchar](8000) NULL, [Subregion] [varchar](8000) NULL, [Location] [varchar](8000) NULL, [LatestRecordedPopulation] [bigint] NULL, [ValidFrom] [datetime2](6) NULL, [ValidTo] [datetime2](6) NULL, [LineageKey] [int] NULL ); --fact_sale DROP TABLE IF EXISTS [dbo].[fact_sale]; CREATE TABLE [dbo].[fact_sale] ( [SaleKey] [bigint] NULL, [CityKey] [int] NULL, [CustomerKey] [int] NULL, [BillToCustomerKey] [int] NULL, [StockItemKey] [int] NULL, [InvoiceDateKey] [datetime2](6) NULL, [DeliveryDateKey] [datetime2](6) NULL, [SalespersonKey] [int] NULL, [WWIInvoiceID] [int] NULL, [Description] [varchar](8000) NULL, [Package] [varchar](8000) NULL, [Quantity] [int] NULL, [UnitPrice] [decimal](18, 2) NULL, [TaxRate] [decimal](18, 3) NULL, [TotalExcludingTax] [decimal](29, 2) NULL, [TaxAmount] [decimal](38, 6) NULL, [Profit] [decimal](18, 2) NULL, [TotalIncludingTax] [decimal](38, 6) NULL, [TotalDryItems] [int] NULL, [TotalChillerItems] [int] NULL, [LineageKey] [int] NULL, [Month] [int] NULL, [Year] [int] NULL, [Quarter] [int] NULL );
Select Run to execute the query.
To save this query for reference later, right-click on the query tab, and select Rename.
Type
Create Tables
to change the name of the query.Press Enter on the keyboard or select anywhere outside the tab to save the change.
Validate the table was created successfully by selecting the refresh icon button on the ribbon.
In the Object explorer, verify that you can see the newly created Create Tables query,
fact_sale
table, anddimension_city
table.