Bagikan melalui


Membuat tabel di database SQL di Fabric

Berlaku untuk:Database SQL di Microsoft Fabric

Ada banyak cara untuk membuat tabel di database Fabric SQL. Pilihan utama dalam Fabric termasuk menggunakan editor SQL untuk membuat tabel, membuat tabel pada beban menggunakan Fabric Data Flows, atau Fabric Pipelines. Untuk panduan ini, kami menggunakan editor kueri portal Fabric untuk database Fabric SQL.

Prasyarat

  • Anda memerlukan kapasitas Fabric yang ada. Jika tidak, mulai uji coba Fabric.
  • Buat ruang kerja baru atau gunakan ruang kerja Fabric yang ada.
  • Buat database SQL baru atau gunakan database SQL yang sudah ada.

Membuat tabel dengan kueri T-SQL

  1. Buka database SQL Anda.

  2. Pilih tombol Kueri Baru di pita utama.

  3. Buat definisi tabel Anda di T-SQL dengan bantuan intellisense, atau gunakan sampel ini:

    CREATE TABLE dbo.products ( 
    product_id INT IDENTITY(1000,1) PRIMARY KEY, 
    product_name VARCHAR(256), 
    create_date DATETIME2 
    ) 
    
  4. Setelah Anda memiliki desain tabel yang Anda suka, pilih Jalankan di toolbar jendela kueri.

  5. Jika Object Explorer sudah diperluas untuk menampilkan tabel, object Explorer akan secara otomatis di-refresh untuk menampilkan tabel baru saat dibuat. Jika tidak, perluas pohon untuk melihat tabel baru.

Membuat tabel dengan Copilot

  1. Buka database SQL Anda.

  2. Pilih tombol Kueri Baru di pita utama.

  3. Ketik teks berikut sebagai komentar T-SQL ke dalam jendela kueri dan tekan Tab di keyboard Anda:

    --create a new table that to store information about products with some typical columns and a monotonistically increasing primary key called ProductID 
    
  4. Setelah beberapa detik, Copilot akan menghasilkan skrip T-SQL yang disarankan berdasarkan perintah.

  5. Tekan tombol Tab lagi untuk menerima saran Copilot. Hasilnya akan terlihat seperti ini:

    --create a new table that to store information about products with some typical columns and a monotonistically increasing primary key called ProductID 
    CREATE TABLE [dbo].[ProductInformation] ( 
    -- Primary Key for the ProductInformation table 
    [ProductID] INT IDENTITY(1,1) PRIMARY KEY, 
    -- Name of the product 
    [ProductName] VARCHAR(100) NOT NULL, 
    -- Description of the product 
    [Description] VARCHAR(MAX), 
    -- Brand of the product 
    [Brand] VARCHAR(50), 
    -- List price of the product 
    [ListPrice] DECIMAL(10, 2), 
    -- Sale price of the product 
    [SalePrice] DECIMAL(10, 2), 
    -- Item number of the product 
    [ItemNumber] VARCHAR(20), 
    -- Global Trade Item Number of the product 
    [GTIN] VARCHAR(20), 
    -- Package size of the product 
    [PackageSize] VARCHAR(50), 
    -- Category of the product 
    [Category] VARCHAR(50), 
    -- Postal code related to the product 
    [PostalCode] VARCHAR(10), 
    -- Availability of the product 
    [Available] BIT, 
    -- Embedding data of the product 
    [Embedding] VARBINARY(MAX), 
    -- Timestamp when the product was created 
    [CreateDate] DATETIME 
    );
    
  6. Tinjau dan edit T-SQL yang disarankan Copilot agar lebih sesuai dengan kebutuhan Anda.

  7. Setelah Anda memiliki desain tabel yang Anda suka, pilih Jalankan di toolbar jendela kueri.

  8. Jika Object Explorer sudah diperluas untuk menampilkan tabel, object Explorer akan secara otomatis di-refresh untuk menampilkan tabel baru saat dibuat. Jika tidak, perluas pohon untuk melihat tabel baru.

Langkah selanjutnya