cat sql | awk ‘{print " ALTER TABLE tableA ALTER " $1 " TYPE " $2 ";"}‘
有table TableA 的sql创建语句提取关键结构如下:
"createdate" timestamp(6),
"createuserid" varchar(32) COLLATE "pg_catalog"."default",
"owneruserid" varchar(32) COLLATE "pg_catalog"."default",
使用 cat sql | awk ‘{print " ALTER TABLE tableA ALTER " $1 " TYPE " $2 ";"}‘
可将语句转换成 改变表字段(表结构)的语句 (行末行首可能有逗号,要自行去除)
ALTER TABLE epand_asset_maanger ALTER "createdate" TYPE timestamp(6); ALTER TABLE epand_asset_maanger ALTER "createuserid" TYPE varchar(32); ALTER TABLE epand_asset_maanger ALTER "owneruserid" TYPE varchar(32);
原文:https://www.cnblogs.com/whatlonelytear/p/11885055.html