Opplæring: Opprette tabeller i et datalager

Gjelder for: SQL Analytics-endepunkt og Warehouse i Microsoft Fabric

Lær hvordan du oppretter tabeller i datalageret du opprettet i en tidligere del av opplæringen.

Opprett en tabell

  1. Velg Arbeidsområder i navigasjonsmenyen.

  2. Velg arbeidsområdet som er opprettet i opplæringen: Opprett et Microsoft Fabric-dataarbeidsområde, for eksempel Opplæring for datalager.

  3. Velg WideWorldImporters med lagertypen fra elementlisten.

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

  4. Velg Ny SQL-spørring fra båndet.

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

  5. Lim inn følgende kode i redigeringsprogrammet for spørringen.

    /*
    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. Velg Kjør for å kjøre spørringen.

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

  7. Hvis du vil lagre denne spørringen for referanse senere, høyreklikker du på spørringsfanen og velger Gi nytt navn.

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

  8. Skriv inn Create Tables for å endre navnet på spørringen.

  9. Trykk enter på tastaturet, eller velg hvor som helst utenfor fanen for å lagre endringen.

  10. Valider tabellen ble opprettet ved å velge oppdateringsknappen på båndet.

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

  11. Kontroller at du kan se den nyopprettede spørringen, fact_sale tabellen og dimension_city tabellen for oppretting av tabeller i objektutforskeren.

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

Neste trinn