Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Applies to:✅ Warehouse in Microsoft Fabric
I den här självstudien lär du dig hur du klonar en tabell med T-SQL. Mer specifikt lär du dig hur du skapar en tabellkloning med CREATE TABLE AS CLONE OF T-SQL-instruktion.
Note
This tutorial forms part of an end-to-end scenario. För att kunna slutföra den här självstudien måste du först slutföra de här självstudierna:
En klonad tabell ger flera fördelar:
- Du kan använda CREATE TABLE AS CLONE OF T-SQL-instruktionen för att skapa en kopia av en tabell vid den aktuella tidpunkten eller vid en tidigare tidpunkt.
- Du kan klona tabeller i Fabric-portalen. For examples, see Tutorial: Clone tables in the Fabric portal.
- You can query data in a Warehouse as it appeared in the past by using a
SELECTstatement with theOPTIONclause. For more information, see Query data as it existed in the past.
Klona en tabell inom samma schema
I den här uppgiften får du lära dig hur du klonar en tabell i samma schema i lagret.
Ensure that the workspace you created in the first tutorial is open.
In the
Wide World Importerswarehouse, on the Home ribbon, select New SQL query.
Klistra in följande kod i frågeredigeraren. Koden skapar en klon av tabellen
dimension_cityoch tabellenfact_sale.--Create a clone of the dbo.dimension_city table. CREATE TABLE [dbo].[dimension_city1] AS CLONE OF [dbo].[dimension_city]; --Create a clone of the dbo.fact_sale table. CREATE TABLE [dbo].[fact_sale1] AS CLONE OF [dbo].[fact_sale];To execute the query, on the query designer ribbon, select Run.
När exekveringen är klar, välj i fönstret
dimension_city1för att se den inlästa datan i förhandsvisning.
To create a table clone as of a past point in time, in the query editor, paste the following code to replace the existing statements. Koden skapar en klon av tabellen
dimension_cityoch tabellenfact_salevid en viss tidpunkt.--Create a clone of the dbo.dimension_city table at a specific point in time. CREATE TABLE [dbo].[dimension_city2] AS CLONE OF [dbo].[dimension_city] AT '2025-01-01T10:00:00.000'; --Create a clone of the dbo.fact_sale table at a specific point in time. CREATE TABLE [dbo].[fact_sale2] AS CLONE OF [dbo].[fact_sale] AT '2025-01-01T10:00:00.000';Viktig
You should replace the timestamp with a past date that is within 30 days of today, but after the date and time (in Coordinated Universal Time—UTC) that you completed the Ingest data into a Warehouse tutorial.
Kör sökfrågan.
When execution completes, preview the data loaded into the
fact_sale2table.Byt namn på frågan till
Clone Tables.
Klona en tabell mellan scheman i samma lager
I den här uppgiften får du lära dig hur du klonar en tabell mellan scheman i samma lager.
Om du vill skapa en ny fråga i menyfliksområdet Start väljer du Ny SQL-fråga.
Klistra in följande kod i frågeredigeraren. Koden skapar ett schema och skapar sedan en klon av tabellen
fact_saleoch tabellendimension_cityi det nya schemat.--Create a new schema within the warehouse named dbo1. CREATE SCHEMA dbo1; GO --Create a clone of dbo.fact_sale table in the dbo1 schema. CREATE TABLE [dbo1].[fact_sale1] AS CLONE OF [dbo].[fact_sale]; --Create a clone of dbo.dimension_city table in the dbo1 schema. CREATE TABLE [dbo1].[dimension_city1] AS CLONE OF [dbo].[dimension_city];Kör sökfrågan.
When execution completes, preview the data loaded into the
dimension_city1table in thedbo1schema.Om du vill skapa tabellkloner från och med en tidigare tidpunkti frågeredigeraren klistrar du in följande kod för att ersätta befintliga uttalanden. Koden skapar en klon av tabellen
dimension_cityoch tabellenfact_salevid vissa tidpunkter i det nya schemat.--Create a clone of the dbo.dimension_city table in the dbo1 schema. CREATE TABLE [dbo1].[dimension_city2] AS CLONE OF [dbo].[dimension_city] AT '2025-01-01T10:00:00.000'; --Create a clone of the dbo.fact_sale table in the dbo1 schema. CREATE TABLE [dbo1].[fact_sale2] AS CLONE OF [dbo].[fact_sale] AT '2025-01-01T10:00:00.000';Viktig
You should replace the timestamp with a past date that is within 30 days of today, but after the date and time (in UTC) that you completed the Ingest data into a Warehouse tutorial.
Kör sökfrågan.
When execution completes, preview the data loaded into the
fact_sale2table in thedbo1schema.Byt namn på frågan till
Clone Tables Across Schemas.