Parameter | Required | Description | Remarks |
OR REPLACE | No | If the table specified by <table_name> already exists, you can execute the DROP TABLE statement for the table, and then create a table with the same name for replacement. | You can use this parameter instead of the following statements:
DROP TABLE IF EXISTS <tableName>;
CREATE TABLE <tableName> ...;
Note Limits: You cannot use CREATE OR REPLACE TABLE together with the following syntaxes: |
EXTERNAL | No | Specifies that the table to be created is an external table. | None |
IF NOT EXISTS | No | Specifies whether a table with the same name exists in the database. | If you do not specify the IF NOT EXISTS option and a table with the same name exists, an error is returned. If you specify the IF NOT EXISTS option, a success message is returned regardless of whether a table with the same name exists. The metadata of the existing table remains unchanged. |
table_name | Yes | The name of the table. | The table name is not case-sensitive and cannot contain special characters. The name can contain letters, digits, and underscores (_). The name must start with a letter and cannot exceed 128 bytes in length. If the value of this parameter does not meet the requirements, an error is returned. |
PRIMARY KEY(pk) | No | The primary key of the table. | You can specify one or more columns as the primary key. This indicates that the combination of these columns must be unique in the table. You must comply with the standard SQL syntax for primary keys. The columns that are defined as the primary key must be set to not null and cannot be modified. Important This parameter is only used for Delta Tables. |
col_name | Yes | The name of a table column. | The column name is not case-sensitive and cannot contain special characters. The name can contain letters, digits, and underscores (_). The name must start with a letter and cannot exceed 128 bytes in length. If the value of this parameter does not meet the requirements, an error is returned. |
col_comment | No | The comment of a column. | The comment must be a valid string that does not exceed 1,024 bytes in length. If the value of this parameter does not meet the requirements, an error is returned. |
data_type | Yes | The data type of the column. | Data types include BIGINT, DOUBLE, BOOLEAN, DATETIME, DECIMAL, and STRING. For more information, see Data Type Version Description. |
NOT NULL | No | The NOT NULL attribute can be configured in the CREATE TABLE syntax to specify that the values in a specific column cannot be NULL. | For more information about how to modify the NOT NULL attribute, see Partition Operations. |
default_value | No | The default value for the column. | When the insert operation does not specify this column, the default value is written to the column. Note The current default value does not support functions such as GETDATE() and NOW() . |
table_comment | No | The comment of the table. | The comment must be a valid string that does not exceed 1,024 bytes in length. If the value of this parameter does not meet the requirements, an error is returned. |
LIFECYCLE | No | The lifecycle of the table. | The value must be a positive integer. Unit: days. Non-partitioned tables: If no data is modified within days after the table is last modified, MaxCompute automatically reclaims the table. This operation is similar to the DROP TABLE operation. Partitioned tables: MaxCompute determines whether to reclaim a partition based on the value of LastModifiedTime. Unlike non-partitioned tables, a partitioned table is not deleted even if all of its partitions have been reclaimed. You can configure lifecycles for tables, but not for partitions.
|