Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We propose add the following syntax for REPLACE TABLE AS SELECT  statement:

Code Block
languagejava
REPLACE TABLE table_identifier
[(
 [ < physical_column_definition >, ... ]
 [ < table_constraint >, ... ])]
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, col_name3, ...) ]
[ WITH ( key1=val1, key2=val2, ... ) ]
AS <table subquery>

<physical_column_definition>:
  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
  
<column_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED

<table_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED


Also, we would like to propose to CREATE OR REPLACE TABLE AS  to wrap CREATE TABLE AS SELECT  and REPLACE TABLE AS SELECT  which will create table if the table to be replaced doesn't exist.

Code Block
languagesql
CREATE OR REPLACE TABLE table_identifier
[(
 [ < physical_column_definition >, ... ]
 [ < table_constraint >, ... ])]
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, col_name3, ...) ]
[ WITH ( key1=val1, key2=val2, ... ) ]
AS <table subquery>

<physical_column_definition>:
  column_name column_type [ <column_constraint> ] [COMMENT column_comment]
  
<column_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY NOT ENFORCED

<table_constraint>:
  [CONSTRAINT constraint_name] PRIMARY KEY (column_name, ...) NOT ENFORCED


Public Interfaces Change

We propose the following public interface changes for REPLACE TABLE AS SELECT  statement:

...