字段名重命名
保留关键字作字段名
在GaussDB(DWS)中保留关键字作字段名需要加双引号,目前工具支持的保留关键字有desc、checksum、operator、size等。
输入示例
1 2 3 4 5 6 7 |
CREATE TABLE `desc` ( user char, checksum int, operator smallint, desc char, size bigint ); |
输出示例
1 2 3 4 5 6 7 |
CREATE TABLE "public"."desc" ( "user" CHAR(4), "checksum" INTEGER, "operator" SMALLINT, "desc" CHAR(4), "size" BIGINT ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("user"); |
系统表隐藏字段名作字段名
定义字段名和GaussDB(DWS)中系统表隐藏字段重名,需重新命名:包括xc_node_id,tableoid, cmax, xmax, cmin, xmin, ctid, tid;重新命名方式,字段后加_new,例如xc_node_id改为xc_node_id_new。
输入示例
1 2 3 4 5 6 7 8 9 10 11 12 |
DROP TABLE IF EXISTS `renameFieldName`; CREATE TABLE IF NOT EXISTS `renameFieldName`( xc_node_id int, tableoid char(3), cmax smallint, xmax bigint auto_increment, cmin varchar(10), xmin int, ctid int auto_increment, tid int ); DROP TABLE IF EXISTS `renameFieldName`; |
输出示例
1 2 3 4 5 6 7 8 9 10 11 12 |
DROP TABLE IF EXISTS "public"."renamefieldname"; CREATE TABLE IF NOT EXISTS "public"."renamefieldname" ( "xc_node_id_new" INTEGER, "tableoid_new" CHAR(12), "cmax_new" SMALLINT, "xmax_new" BIGSERIAL, "cmin_new" VARCHAR(40), "xmin_new" INTEGER, "ctid_new" SERIAL, "tid_new" INTEGER ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("xc_node_id_new"); DROP TABLE IF EXISTS "public"."renamefieldname"; |