odps表格创建操作

一个语句,创建和源表格式相同并且带字段注释的表格方法:create table [if not exists] <table_name> like <existing_table_name> [lifecycle <days>];

而这个语句create table [if not exists] <table_name> as <select_statement>; 会创建一个新表,但是不会将源表的元数据复制到新表中.元数据包括列名、列类型、列注释、分区等信息。因此,使用这种方式创建的新表只会继承源表的列名和列类型,而不会继承源表的列注释。但是他会把源表所有数据插入新的表格

示例:

CREATE TABLE IF NOT EXISTS table_name LIKE a.table_name;  

create table if not exists table_name as select * from a.table_name;

Leave a Reply

Your email address will not be published. Required fields are marked *