代码出自导师之手,特此记录,方便下次使用。
SET SESSION group_concat_max_len = 10240;
select
concat_ws
('\n'
,concat('create table ods.ods_{库名}_','{表名}','_dt')
,'('
,group_concat(
concat_ws
(' '
,case when t.ORDINAL_POSITION = 1 then ' ' else ',' end
,t.column_name
,t.hive_data_type
,'COMMENT'
,concat('''',t.COL