Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
Applies to:✅ Warehouse in Microsoft Fabric
В этом руководстве описано, как создавать таблицы в хранилище с помощью T-SQL.
Заметка
This tutorial forms part of an end-to-end scenario. Чтобы завершить это руководство, необходимо сначала выполнить эти уроки.
Создание таблиц
В этой задаче вы узнаете, как создавать таблицы в хранилище с помощью T-SQL.
Ensure that the workspace you created in the first tutorial is open.
Select the Wide World Importers warehouse (from the items listed on the workspace landing page).
На ленте Главная выберите Новый SQL-запрос.
In the query editor, paste the following code. Код удаляет таблицу
dimension_city
(если она существует), а затем создает таблицу измерений. Она также удаляет таблицуfact_sale
(если она существует) и создает таблицу фактов.--Drop the dimension_city table if it already exists. DROP TABLE IF EXISTS [dbo].[dimension_city]; --Create the dimension_city table. 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 ); --Drop the fact_sale table if it already exists. DROP TABLE IF EXISTS [dbo].[fact_sale]; --Create the fact_sale table. 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 );
To execute the query, on the query designer ribbon, select Run.
Когда выполнение скрипта завершится, чтобы переименовать запрос, щелкните правой кнопкой мыши вкладку запроса и выберите Переименовать.
In the Rename window, in the Name box, replace the default name with
Create Tables
.Выберите Переименовать.
If necessary, in the Explorer pane, expand the Schemas folder, the
dbo
schema, and the Tables folder.Убедитесь, что перечислены две новые таблицы. The
dimension_customer
table was created in the previous tutorial.
Next step
Руководство по . Загрузка данных с помощью T-SQL в хранилище