Files
doris/docs/en/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md
Mingyu Chen 74a482ca7f [fix] fix docs build bug (#9293)
After this PR #9272, the `docs/build_help_zip.sh` will run failed.
This PR fix this issue.
But the help module still has some parse problem, I will fix it in next PR.

This CL mainly changes:
1. fix `docs/build_help_zip.sh` error
2. remove `sql-reference-v2` to `sql-reference`
3. modify build extension github action to run `docs/build_help_zip.sh`
2022-04-28 22:19:04 +08:00

3.1 KiB

title, language
title language
CREATE-TABLE-LIKE en

CREATE-TABLE-LIKE

Name

CREATE TABLE LIKE

Description

This statement is used to create an empty table with the exact same table structure as another table, and can optionally replicate some rollups.

grammar:

CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name LIKE [database.]table_name [WITH ROLLUP (r1,r2,r3,...)]

illustrate:

  • The copied table structure includes Column Definition, Partitions, Table Properties, etc.
  • The user needs to have SELECT permission on the copied original table
  • Support for copying external tables such as MySQL
  • Support the rollup of copying OLAP Table

Example

  1. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2

    CREATE TABLE test1.table2 LIKE test1.table1
    
  2. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2

    CREATE TABLE test2.table2 LIKE test1.table1
    
  3. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time

    CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP (r1,r2)
    
  4. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy all the rollups of table1 at the same time

    CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP
    
  5. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time

    CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP (r1,r2)
    
  6. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy all the rollups of table1 at the same time

    CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP
    
  7. Create an empty table under the test1 library with the same table structure as the MySQL outer table1, the table name is table2

    CREATE TABLE test1.table2 LIKE test1.table1
    

Keywords

CREATE, TABLE, LIKE

Best Practice