Tutorial: Membuat tabel di gudang data

Berlaku untuk: Titik akhir analitik SQL dan Gudang di Microsoft Fabric

Pelajari cara membuat tabel di gudang data yang Anda buat di bagian tutorial sebelumnya.

Buat tabel

  1. Pilih Ruang Kerja di menu navigasi.

  2. Pilih ruang kerja yang dibuat di Tutorial: Membuat ruang kerja data Microsoft Fabric, seperti Tutorial Gudang Data.

  3. Dari daftar item, pilih WideWorldImporters dengan jenis Gudang.

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

  4. Dari pita, pilih Kueri SQL baru.

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

  5. Di editor kueri, tempelkan kode berikut.

    /*
    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. Pilih Jalankan untuk menjalankan kueri.

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

  7. Untuk menyimpan kueri ini untuk referensi nanti, klik kanan pada tab kueri, dan pilih Ganti Nama.

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

  8. Ketik Create Tables untuk mengubah nama kueri.

  9. Tekan Enter pada keyboard atau pilih di mana saja di luar tab untuk menyimpan perubahan.

  10. Validasi tabel berhasil dibuat dengan memilih tombol refresh pada pita.

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

  11. Di Object explorer, verifikasi bahwa Anda bisa melihat kueri Buat Tabel, tabel, fact_sale dan dimension_city tabel yang baru dibuat.

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

Langkah selanjutnya