CREATE TABLE LIKE (SQL Analytics)

Defines a table using the definition and metadata of an existing table or view.

Delta Lake does not support CREATE TABLE LIKE. Instead use CREATE TABLE AS. See AS.

Syntax

CREATE TABLE [ IF NOT EXISTS ] table_identifier LIKE source_table_identifier
    USING data_source
    [ TBLPROPERTIES ( key1=val1, key2=val2, ... ) ]
    LOCATION path

Parameters

  • table_identifier

    A table name, optionally qualified with a database name.

    Syntax: [database_name.] table_name

  • USING data_source

    The file format to use for the table. data_source must be one of TEXT, CSV, JSON, JDBC, PARQUET, or ORC. You must also specify LOCATION.

  • TBLPROPERTIES

    A list of key-value pairs used to tag the table definition.

  • LOCATION

    Path to the directory where table data is stored, which could be a path on distributed storage. Location to create an external table.

Examples

-- Create table using a new location
CREATE TABLE Student_Dupli LIKE Student LOCATION '/mnt/data_files';

-- Create table like using a data source
CREATE TABLE Student_Dupli LIKE Student USING CSV LOCATION '/mnt/csv_files';