Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Applies to:✅ Warehouse in Microsoft Fabric
Questa esercitazione illustra come clonare una tabella con T-SQL. Specifically, you learn how to create a table clone with the CREATE TABLE AS CLONE OF T-SQL statement.
Nota
This tutorial forms part of an end-to-end scenario. Per completare questa esercitazione, è prima necessario completare queste esercitazioni:
Una tabella clonata offre diversi vantaggi:
- You can use the CREATE TABLE AS CLONE OF T-SQL statement to create a table clone at the current point-in-time or at a previous point-in-time.
- È possibile clonare tabelle nel portale di Fabric. 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
SELECT
statement with theOPTION
clause. For more information, see Query data as it existed in the past.
Clonare una tabella nello stesso schema
In this task, learn how to clone a table within the same schema in the warehouse.
Ensure that the workspace you created in the first tutorial is open.
In the
Wide World Importers
warehouse, on the Home ribbon, select New SQL query.Nell'editor di query incollare il codice seguente. Il codice crea un clone della tabella
dimension_city
e della tabellafact_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.
Al termine dell'esecuzione, per visualizzare in anteprima i dati caricati, nel riquadro Esplora, selezionare
dimension_city1
.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. Il codice crea un clone della tabella
dimension_city
e della tabellafact_sale
in un determinato momento.--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';
Important
È consigliabile sostituire il timestamp con una data precedente, che sia entro 30 giorni da oggi, ma successiva alla data e ora (in Tempo Coordinato Universale - UTC) in cui hai completato il tutorial Ingestione dati in un Data Warehouse.
Run the query.
Al termine dell'esecuzione, visualizzare in anteprima i dati caricati nella tabella
fact_sale2
.Rename the query as
Clone Tables
.
Clone a table across schemas within the same warehouse
In questa attività, imparerai come clonare una tabella attraverso gli schemi all'interno dello stesso magazzino.
To create a new query, on the Home ribbon, select New SQL query.
Nell'editor di query incollare il codice seguente. Il codice crea uno schema e quindi crea un clone della tabella
fact_sale
e della tabelladimension_city
nel nuovo schema.--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];
Run the query.
Al termine dell'esecuzione, visualizzare in anteprima i dati caricati nella tabella
dimension_city1
nello schemadbo1
.To create table clones as of a previous point in time, in the query editor, paste the following code to replace the existing statements. Il codice crea un clone della tabella
dimension_city
e della tabellafact_sale
in determinati momenti nel nuovo schema.--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';
Important
Dovresti sostituire il timestamp con una data passata entro 30 giorni da oggi, ma successiva alla data e ora (in UTC) in cui hai completato il tutorial sull'inserimento di dati in un magazzino.
Run the query.
Al termine dell'esecuzione, visualizzare in anteprima i dati caricati nella tabella
fact_sale2
nello schemadbo1
.Rename the query as
Clone Tables Across Schemas
.