重命名记录中的字段时在SQL中创建表(BigQuery)
我试图在我的数据仓库中创建一个新表,我需要重命名字段。 我正在为此使用BigQuery 基本表中的字段及其类型如下所示:重命名记录中的字段时在SQL中创建表(BigQuery),sql,google-bigquery,record,Sql,Google Bigquery,Record,我试图在我的数据仓库中创建一个新表,我需要重命名字段。 我正在为此使用BigQuery 基本表中的字段及其类型如下所示: created STRING fields_count INTEGER fields_type STRING fields_data RECORD value STRING label STRING 我不知道如何将表中的记录展平,以便能够创建新的结构如果您使用的是sql serve
created STRING
fields_count INTEGER
fields_type STRING
fields_data RECORD
value STRING
label STRING
我不知道如何将表中的记录展平,以便能够创建新的结构如果您使用的是sql server,那么:
select created new_created, fields_count new_fields_count ,fields_type new_fields_type, fields_data new_fields_data, [value] new_value, label new_label into newtable from oldtable
以上sql将从oldtable创建新表,列名前缀为new
对于BigQuery:
Create table newtable
as select created new_created, fields_count new_fields_count ,fields_type new_fields_type, fields_data new_fields_data, [value] new_value, label new_label from oldtable
请共享您的dbms名称和新表的结构。我正在使用BigQuery。