Esercitazione: Creare tabelle in un data warehouse

Si applica a: Endpoint di analisi SQL e Warehouse in Microsoft Fabric

Informazioni su come creare tabelle nel data warehouse creato in una parte precedente dell'esercitazione.

Crea una tabella

  1. Selezionare Aree di lavoro nel menu di spostamento.

  2. Selezionare l'area di lavoro creata in Esercitazione: Creare un'area di lavoro dati di Microsoft Fabric, ad esempio Esercitazione sul data warehouse.

  3. Nell'elenco di elementi selezionare WideWorldImporters con il tipo di Warehouse.

    Screenshot of the warehouse option that appears in the item list.

  4. Nella barra multifunzione selezionare Nuova query SQL.

    Screenshot of the New SQL query option where it appears on the ribbon.

  5. Nell'editor di query incollare il codice seguente.

    /*
    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
        );
    
  6. Selezionare Esegui per eseguire la query.

    Screenshot of the top corner of the query editor screen, showing where to select Run.

  7. Per salvare la query per riferimento in un secondo momento, fare clic con il pulsante destro del mouse sulla scheda query e scegliere Rinomina.

    Screenshot of the top corner of the query editor screen, showing where to right-click to select the Rename option.

  8. Digitare Create Tables per modificare il nome della query.

  9. Premere INVIO sulla tastiera o selezionare un punto qualsiasi all'esterno della scheda per salvare la modifica.

  10. Verificare che la tabella sia stata creata correttamente selezionando il pulsante Aggiorna sulla barra multifunzione.

    Screenshot of the ribbon on the Home screen, showing where to select the refresh option.

  11. In Esplora oggetti verificare che sia possibile visualizzare la query, fact_sale la tabella e dimension_city la tabella create di recente.

    Screenshot of the Explorer pane, showing where to find your tables and newly created query.

Passaggio successivo