CREATE TABLE AS SELECT
This statement creates the table structure by returning the results from the Select statement and imports the data at the same time
grammar:
CREATE TABLE table_name [( column_name_list )] opt_engine opt_partition opt_properties KW_AS query_stmt
illustrate:
decimalare not currently supportedSELECTpermission for the source table andCREATEpermission for the target databaseUsing the field names in the SELECT statement
create table `test`.`select_varchar` PROPERTIES(\"replication_num\" = \"1\") as select * from `test`.`varchar_table`
Custom field names (need to match the number of fields returned)
create table `test`.`select_name`(user, testname, userstatus) PROPERTIES(\"replication_num\" = \"1\") as select vt.userId, vt.username, jt.status from `test`.`varchar_table` vt join `test`.`join_table` jt on vt.userId=jt.userId
CREATE, TABLE, AS, SELECT