云数据库 GAUSSDB-使用CREATE TABLE LIKE执行深层复制:操作步骤

时间:2024-01-23 20:08:32

操作步骤

  1. 使用CREATE TABLE LIKE语句创建表customer_t的副本customer_t_copy。

    1
    openGauss=# CREATE TABLE customer_t_copy (LIKE customer_t);
    

  2. 使用INSERT INTO…SELECT语句向副本填充原始表中的数据。

    1
    openGauss=# INSERT INTO customer_t_copy (SELECT * FROM customer_t);
    

  3. 删除原始表。

    1
    openGauss=# DROP TABLE customer_t;
    

  4. 使用ALTER TABLE语句将副本重命名为原始表名称。

    1
    openGauss=# ALTER TABLE customer_t_copy RENAME TO customer_t;
    

support.huaweicloud.com/centralized-devg-v2-gaussdb/devg_03_0271.html