You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/07 01:39:03 UTC

[shardingsphere] branch master updated: support pg create table sql for multi version -2 (#17384)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new d7a8079e514 support pg create table sql for multi version -2 (#17384)
d7a8079e514 is described below

commit d7a8079e5141474e47e4aaa42221feda32047964
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Sat May 7 09:38:58 2022 +0800

    support pg create table sql for multi version -2 (#17384)
    
    * support pg create table for multi version -2
    
    * support get pg create sql for multi version - 2
---
 .../PostgresColumnPropertiesLoader.java            |   2 +-
 .../ddlgenerator/PostgresConstraintsLoader.java    |  28 ++++--
 .../postgresql/util/FreemarkerManager.java         |   2 +-
 .../9.2_plus/{get_cols.ftl => properties.ftl}      |   0
 .../template/columns/10_plus/properties.ftl        |  55 +++++++++++
 .../exclusion_constraint/default/properties.ftl    |  47 +++++++++
 .../index_constraint/default/properties.ftl        |  48 ++++++++++
 .../resources/template/table/10_plus/create.ftl    | 105 +++++++++++++++++++++
 .../template/table/10_plus/properties.ftl          |  91 ++++++++++++++++++
 .../resources/template/table/11_plus/create.ftl    | 105 +++++++++++++++++++++
 .../template/table/11_plus/properties.ftl          |  92 ++++++++++++++++++
 11 files changed, 564 insertions(+), 11 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresColumnPropertiesLoader.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresColumnPropertiesLoader.java
index eebfd9e498d..930d3dfe799 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresColumnPropertiesLoader.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresColumnPropertiesLoader.java
@@ -138,7 +138,7 @@ public final class PostgresColumnPropertiesLoader extends PostgresAbstractLoader
         handlePrimaryColumn(column);
         fetchLengthPrecision(column);
         editTypes.add(column.get("cltype").toString());
-        column.put("edit_types", editTypes);
+        column.put("edit_types", editTypes.stream().sorted().collect(Collectors.toList()));
         column.put("cltype", parseTypeName(column.get("cltype").toString()));
     }
     
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsLoader.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsLoader.java
index ba8f5365770..b65db0922c8 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsLoader.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ddlgenerator/PostgresConstraintsLoader.java
@@ -33,6 +33,8 @@ import java.util.stream.Collectors;
  */
 public final class PostgresConstraintsLoader extends PostgresAbstractLoader {
     
+    private static final Integer PG_CONSTRAINTS_INCLUDE_VERSION = 11;
+    
     public PostgresConstraintsLoader(final Connection connection, final int majorVersion, final int minorVersion) {
         super(connection, majorVersion, minorVersion);
     }
@@ -85,14 +87,20 @@ public final class PostgresConstraintsLoader extends PostgresAbstractLoader {
                 columns.add(column);
             }
             each.put("columns", columns);
-            Map<String, Object> parameters = new LinkedHashMap<>();
-            parameters.put("cid", each.get("oid"));
-            Collection<Object> includes = new LinkedList<>();
-            for (Map<String, Object> include : executeByTemplate(parameters, "index_constraint/%s/get_constraint_include.ftl")) {
-                includes.add(include.get("colname"));
+            appendConstraintsInclude(each);
+        }
+    }
+    
+    private void appendConstraintsInclude(final Map<String, Object> constraintsProp) {
+        Map<String, Object> parameters = new LinkedHashMap<>();
+        parameters.put("cid", constraintsProp.get("oid"));
+        Collection<Object> includes = new LinkedList<>();
+        if (getMajorVersion() >= PG_CONSTRAINTS_INCLUDE_VERSION) {
+            for (Map<String, Object> each : executeByTemplate(parameters, "index_constraint/%s/get_constraint_include.ftl")) {
+                includes.add(each.get("colname"));
             }
-            each.put("include", includes);
         }
+        constraintsProp.put("include", includes);
     }
     
     private String stripQuote(final String column) {
@@ -155,8 +163,10 @@ public final class PostgresConstraintsLoader extends PostgresAbstractLoader {
         Map<String, Object> map = new HashMap<>();
         map.put("cid", exclusionConstraintsProps.get("oid"));
         Collection<String> include = new LinkedList<>();
-        for (Map<String, Object> each : executeByTemplate(map, "exclusion_constraint/%s/get_constraint_include.ftl")) {
-            include.add(each.get("colname").toString());
+        if (getMajorVersion() >= PG_CONSTRAINTS_INCLUDE_VERSION) {
+            for (Map<String, Object> each : executeByTemplate(map, "exclusion_constraint/%s/get_constraint_include.ftl")) {
+                include.add(each.get("colname").toString());
+            }
         }
         exclusionConstraintsProps.put("include", include);
     }
@@ -257,6 +267,6 @@ public final class PostgresConstraintsLoader extends PostgresAbstractLoader {
     private Collection<Map<String, Object>> getCheckConstraints(final Long tid) {
         Map<String, Object> parameters = new HashMap<>();
         parameters.put("tid", tid);
-        return executeByTemplate(parameters, "check_constraint/%s/get_cols.ftl");
+        return executeByTemplate(parameters, "check_constraint/%s/properties.ftl");
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/util/FreemarkerManager.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/util/FreemarkerManager.java
index bd512d0dad8..f6334bcd205 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/util/FreemarkerManager.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/util/FreemarkerManager.java
@@ -88,7 +88,7 @@ public final class FreemarkerManager {
      */
     @SneakyThrows
     public static String getSqlByPgVersion(final Map<String, Object> data, final String pathFormat, final int majorVersion, final int minorVersion) {
-        int version = majorVersion * 10000 + minorVersion * 100;
+        int version = majorVersion * 10000 + minorVersion;
         try (StringWriter result = new StringWriter()) {
             findTemplate(pathFormat, version).orElseThrow(() -> new ShardingSphereException("Failed to get template, path:%s, version:%s", pathFormat, version)).process(data, result);
             return result.toString();
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/check_constraint/9.2_plus/get_cols.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/check_constraint/9.2_plus/properties.ftl
similarity index 100%
rename from shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/check_constraint/9.2_plus/get_cols.ftl
rename to shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/check_constraint/9.2_plus/properties.ftl
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/columns/10_plus/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/columns/10_plus/properties.ftl
new file mode 100644
index 00000000000..973ed4ff6b5
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/columns/10_plus/properties.ftl
@@ -0,0 +1,55 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT att.attname as name, att.atttypid, att.attlen, att.attnum, att.attndims,
+att.atttypmod, att.attacl, att.attnotnull, att.attoptions, att.attstattarget,
+att.attstorage, att.attidentity,
+pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
+pg_catalog.format_type(ty.oid,NULL) AS typname,
+pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname,
+pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype,
+CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid,
+(SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = ty.typnamespace) as typnspname,
+ty.typstorage AS defaultstorage,
+description, pi.indkey,
+(SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup,
+CASE WHEN length(coll.collname::text) > 0 AND length(nspc.nspname::text) > 0  THEN
+pg_catalog.concat(pg_catalog.quote_ident(nspc.nspname),'.',pg_catalog.quote_ident(coll.collname))
+ELSE '' END AS collspcname,
+EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk,
+(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels,
+(CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column,
+(CASE WHEN (att.attidentity in ('a', 'd')) THEN 'i' ELSE 'n' END) AS colconstype, tab.relname as relname,
+(CASE WHEN tab.relkind = 'v' THEN true ELSE false END) AS is_view_only,
+seq.*
+FROM pg_catalog.pg_attribute att
+JOIN pg_catalog.pg_type ty ON ty.oid=atttypid
+LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN (pg_catalog.pg_depend dep JOIN pg_catalog.pg_class cs ON dep.classid='pg_class'::regclass AND dep.objid=cs.oid AND cs.relkind='S') ON dep.refobjid=att.attrelid AND dep.refobjsubid=att.attnum
+LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary
+LEFT OUTER JOIN pg_catalog.pg_collation coll ON att.attcollation=coll.oid
+LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid
+LEFT OUTER JOIN pg_catalog.pg_sequence seq ON cs.oid=seq.seqrelid
+LEFT OUTER JOIN pg_catalog.pg_class tab on tab.oid = att.attrelid
+WHERE att.attrelid = ${tid?c}::oid
+<#if clid?? >
+AND att.attnum = ${clid?c}::int
+</#if>
+AND att.attnum > 0
+AND att.attisdropped IS FALSE
+ORDER BY att.attnum;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/exclusion_constraint/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/exclusion_constraint/default/properties.ftl
new file mode 100644
index 00000000000..da8a737457b
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/exclusion_constraint/default/properties.ftl
@@ -0,0 +1,47 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT cls.oid,
+cls.relname as name,
+indnatts as col_count,
+amname,
+CASE WHEN length(spcname::text) > 0 THEN spcname ELSE
+(SELECT sp.spcname FROM pg_catalog.pg_database dtb
+JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
+WHERE dtb.oid = ${ did?c }::oid)
+END as spcname,
+CASE contype
+WHEN 'p' THEN desp.description
+WHEN 'u' THEN desp.description
+WHEN 'x' THEN desp.description
+ELSE des.description
+END AS comment,
+condeferrable,
+condeferred,
+substring(pg_catalog.array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor,
+pg_catalog.pg_get_expr(idx.indpred, idx.indrelid, true) AS indconstraint
+FROM pg_catalog.pg_index idx
+JOIN pg_catalog.pg_class cls ON cls.oid=indexrelid
+LEFT OUTER JOIN pg_catalog.pg_tablespace ta on ta.oid=cls.reltablespace
+JOIN pg_catalog.pg_am am ON am.oid=cls.relam
+LEFT JOIN pg_catalog.pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_constraint') AND dep.deptype='i')
+LEFT OUTER JOIN pg_catalog.pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
+WHERE indrelid = ${tid?c}::oid
+AND contype='x'
+ORDER BY cls.relname
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/index_constraint/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/index_constraint/default/properties.ftl
new file mode 100644
index 00000000000..e7c29d5a58d
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/index_constraint/default/properties.ftl
@@ -0,0 +1,48 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT cls.oid,
+cls.relname as name,
+indnatts as col_count,
+CASE WHEN length(spcname::text) > 0 THEN spcname ELSE
+(SELECT sp.spcname FROM pg_catalog.pg_database dtb
+JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
+WHERE dtb.oid = ${ did?c }::oid)
+END as spcname,
+CASE contype
+WHEN 'p' THEN desp.description
+WHEN 'u' THEN desp.description
+WHEN 'x' THEN desp.description
+ELSE des.description
+END AS comment,
+condeferrable,
+condeferred,
+conislocal,
+substring(pg_catalog.array_to_string(cls.reloptions, ',') from 'fillfactor=([0-9]*)') AS fillfactor
+FROM pg_catalog.pg_index idx
+JOIN pg_catalog.pg_class cls ON cls.oid=indexrelid
+LEFT OUTER JOIN pg_catalog.pg_tablespace ta on ta.oid=cls.reltablespace
+LEFT JOIN pg_catalog.pg_depend dep ON (dep.classid = cls.tableoid AND dep.objid = cls.oid AND dep.refobjsubid = '0' AND dep.refclassid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='pg_constraint') AND dep.deptype='i')
+LEFT OUTER JOIN pg_catalog.pg_constraint con ON (con.tableoid = dep.refclassid AND con.oid = dep.refobjid)
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=cls.oid AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN pg_catalog.pg_description desp ON (desp.objoid=con.oid AND desp.objsubid = 0 AND desp.classoid='pg_constraint'::regclass)
+WHERE indrelid = ${tid?c}::oid
+<#if cid?? >
+    AND cls.oid = ${cid?c}::oid
+</#if>
+AND contype='${constraint_type}'
+ORDER BY cls.relname
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/create.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/create.ftl
new file mode 100644
index 00000000000..f7ab015dc90
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/create.ftl
@@ -0,0 +1,105 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<#import "../../macro/constraints.ftl" as CONSTRAINTS>
+CREATE <#if relpersistence!false >UNLOGGED </#if>TABLE IF NOT EXISTS ${schema}.${name}
+<#if typname?? >
+OF ${typname }
+</#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+(
+</#if>
+<#if like_relation?? >
+LIKE ${like_relation }<#if like_default_value!false >
+INCLUDING DEFAULTS</#if><#if like_constraints!false >
+INCLUDING CONSTRAINTS</#if><#if like_indexes!false >
+INCLUDING INDEXES</#if><#if like_storage!false >
+INCLUDING STORAGE</#if><#if  like_comments!false >
+INCLUDING COMMENTS</#if><#if  columns?size gt 0 >,
+</#if>
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.name?? && c.cltype?? >
+<#if c.inheritedfromtable?? >-- Inherited from table ${c.inheritedfromtable}: <#elseif c.inheritedfromtype?? >-- Inherited from type ${c.inheritedfromtype}: </#if>${c.name} ${c.displaytypname}<#if c.collspcname?? && c.collspcname?length gt 0 > COLLATE ${c.collspcname}</#if><#if c.attnotnull!false > NOT NULL</#if><#if c.defval?? && c.defval != ''> DEFAULT ${c.defval}</#if>
+<#if c.colconstype?? && c.colconstype == 'i' && c.attidentity?? && c.attidentity != '' >
+<#if c.attidentity?? &&  c.attidentity == 'a' > GENERATED ALWAYS AS IDENTITY<#elseif c.attidentity?? && c.attidentity == 'd' > GENERATED BY DEFAULT AS IDENTITY</#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? > ( </#if>
+<#if c.seqcycle!false >
+CYCLE </#if><#if c.seqincrement?? && c.seqincrement?number gt -1 >
+INCREMENT ${c.seqincrement} </#if><#if c.seqstart?? && c.seqstart?number gt -1>
+START ${c.seqstart} </#if><#if c.seqmin?? && c.seqmin?number gt -1>
+MINVALUE ${c.seqmin} </#if><#if c.seqmax?? && c.seqmax?number gt -1>
+MAXVALUE ${c.seqmax} </#if><#if c.seqcache?? && c.seqcache?number gt -1>
+CACHE ${c.seqcache} </#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? >)</#if>
+</#if>
+<#if c?counter lt columns?size>,
+</#if>
+</#if>
+</#list>
+</#if>
+<#if primary_key?size gt 0 ><#if columns?size gt 0 >,</#if>
+<@CONSTRAINTS.PRIMARY_KEY data=primary_key[0] /></#if><#if unique_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 >,</#if>
+<@CONSTRAINTS.UNIQUE unique_data=unique_constraint /></#if><#if foreign_key?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.FOREIGN_KEY foreign_key_data=foreign_key /></#if><#if check_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 >,</#if>
+<@CONSTRAINTS.CHECK check_data=check_constraint/></#if><#if exclude_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.EXCLUDE exclude_data=exclude_constraint/></#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+)</#if><#if relkind?? && relkind == 'p' > PARTITION BY ${ partition_scheme }</#if>
+<#if coll_inherits?? && coll_inherits?size gt 0>
+INHERITS (<#list coll_inherits as val ><#if val?counter != 1 >, </#if>${val}</#list>)
+</#if>
+WITH (
+OIDS = <#if relhasoids!false >TRUE<#else>FALSE</#if><#if fillfactor?? >,
+FILLFACTOR = ${ fillfactor }</#if><#if parallel_workers?? && parallel_workers != '' >,
+parallel_workers = ${ parallel_workers }</#if><#if toast_tuple_target?? && toast_tuple_target != ''>,
+toast_tuple_target = ${ data.toast_tuple_target }</#if><#if autovacuum_enabled?? && (autovacuum_enabled == 't' || autovacuum_enabled == 'f') >,
+autovacuum_enabled = <#if autovacuum_enabled == 't' >TRUE<#else >FALSE</#if></#if><#if toast_autovacuum_enabled?? && (toast_autovacuum_enabled == 't' || toast_autovacuum_enabled == 'f')  >,
+toast.autovacuum_enabled = <#if toast_autovacuum_enabled == 't' >TRUE<#else >FALSE</#if>
+</#if><#if autovacuum_custom!false && vacuum_table?size gt 0 >
+<#list vacuum_table as opt ><#if opt.name?? && opt.value?? >
+,
+${opt.name} = ${opt.value}</#if>
+</#list></#if><#if toast_autovacuum!false && vacuum_toast?size gt 0 >
+<#list vacuum_toast as opt ><#if opt.name?? && opt.value?? >
+,
+toast.${opt.name} = ${opt.value}</#if>
+</#list></#if>
+<#if spcname?? >
+)
+TABLESPACE ${spcname };
+<#else>
+);
+</#if>
+<#if description?? >
+COMMENT ON TABLE ${schema}.${name}
+IS '${description}';
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.description?? >
+COMMENT ON COLUMN ${schema}.${name}.${c.name}
+IS '${c.description}';
+</#if>
+</#list>
+</#if>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=primary_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=unique_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=foreign_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=check_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=exclude_constraint/>
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/properties.ftl
new file mode 100644
index 00000000000..dbeb40d4378
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/10_plus/properties.ftl
@@ -0,0 +1,91 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str,
+(CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE
+(SELECT sp.spcname FROM pg_catalog.pg_database dtb
+JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
+WHERE dtb.oid = ${ did?c }::oid)
+END) as spcname,
+(CASE rel.relreplident
+WHEN 'd' THEN 'default'
+WHEN 'n' THEN 'nothing'
+WHEN 'f' THEN 'full'
+WHEN 'i' THEN 'index'
+END) as replica_identity,
+(select nspname FROM pg_catalog.pg_namespace WHERE oid = ${scid?c}::oid ) as schema,
+pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, rel.relkind,
+(CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned,
+rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey,
+EXISTS(select 1 FROM pg_catalog.pg_trigger
+JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger'
+JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
+WHERE tgrelid=rel.oid) AS isrepl,
+(SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
+(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
+pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname)
+ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits,
+(SELECT count(*)
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
+(CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers,
+(substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age,
+(substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
+rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype,
+CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = ${scid?c}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname,
+typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy,
+(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
+(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels,
+(CASE WHEN rel.oid <= ${ datlastsysoid?c}::oid THEN true ElSE false END) AS is_sys_table
+-- Added for partition table
+<#if tid?? >, (CASE WHEN rel.relkind = 'p' THEN pg_catalog.pg_get_partkeydef(${ tid?c }::oid) ELSE '' END) AS partition_scheme </#if>
+FROM pg_catalog.pg_class rel
+LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
+LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid
+LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid
+WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ${ scid?c }::oid
+AND NOT rel.relispartition
+<#if tid?? >  AND rel.oid = ${ tid?c }::oid </#if>
+ORDER BY rel.relname;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/create.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/create.ftl
new file mode 100644
index 00000000000..afe8d860a98
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/create.ftl
@@ -0,0 +1,105 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<#import "../../macro/constraints.ftl" as CONSTRAINTS>
+CREATE <#if relpersistence!false >UNLOGGED </#if>TABLE IF NOT EXISTS ${schema}.${name}
+<#if typname?? >
+OF ${typname }
+</#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+(
+</#if>
+<#if like_relation?? >
+LIKE ${like_relation }<#if like_default_value!false >
+INCLUDING DEFAULTS</#if><#if like_constraints!false >
+INCLUDING CONSTRAINTS</#if><#if like_indexes!false >
+INCLUDING INDEXES</#if><#if like_storage!false >
+INCLUDING STORAGE</#if><#if  like_comments!false >
+INCLUDING COMMENTS</#if><#if  columns?size gt 0 >,
+</#if>
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.name?? && c.cltype?? >
+<#if c.inheritedfromtable?? >-- Inherited from table ${c.inheritedfromtable}: <#elseif c.inheritedfromtype?? >-- Inherited from type ${c.inheritedfromtype}: </#if>${c.name} ${c.displaytypname}<#if c.collspcname?? && c.collspcname?length gt 0 > COLLATE ${c.collspcname}</#if><#if c.attnotnull!false > NOT NULL</#if><#if c.defval?? && c.defval != '' && c.colconstype?? && c.colconstype != 'g' > DEFAULT ${c.defval}</#if>
+<#if c.colconstype?? && c.colconstype == 'i' && c.attidentity?? && c.attidentity != '' >
+<#if c.attidentity?? &&  c.attidentity == 'a' > GENERATED ALWAYS AS IDENTITY<#elseif c.attidentity?? && c.attidentity == 'd' > GENERATED BY DEFAULT AS IDENTITY</#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? > ( </#if>
+<#if c.seqcycle!false >
+CYCLE </#if><#if c.seqincrement?? && c.seqincrement?number gt -1 >
+INCREMENT ${c.seqincrement} </#if><#if c.seqstart?? && c.seqstart?number gt -1>
+START ${c.seqstart} </#if><#if c.seqmin?? && c.seqmin?number gt -1>
+MINVALUE ${c.seqmin} </#if><#if c.seqmax?? && c.seqmax?number gt -1>
+MAXVALUE ${c.seqmax} </#if><#if c.seqcache?? && c.seqcache?number gt -1>
+CACHE ${c.seqcache} </#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? >)</#if>
+</#if>
+<#if c?counter lt columns?size>,
+</#if>
+</#if>
+</#list>
+</#if>
+<#if primary_key?size gt 0 ><#if columns?size gt 0 >,</#if>
+<@CONSTRAINTS.PRIMARY_KEY data=primary_key[0] /></#if><#if unique_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 >,</#if>
+<@CONSTRAINTS.UNIQUE unique_data=unique_constraint /></#if><#if foreign_key?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.FOREIGN_KEY foreign_key_data=foreign_key /></#if><#if check_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 >,</#if>
+<@CONSTRAINTS.CHECK check_data=check_constraint/></#if><#if exclude_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.EXCLUDE exclude_data=exclude_constraint/></#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+)</#if><#if relkind?? && relkind == 'p' > PARTITION BY ${ partition_scheme }</#if>
+<#if coll_inherits?? && coll_inherits?size gt 0>
+INHERITS (<#list coll_inherits as val ><#if val?counter != 1 >, </#if>${val}</#list>)
+</#if>
+WITH (
+OIDS = <#if relhasoids!false >TRUE<#else>FALSE</#if><#if fillfactor?? >,
+FILLFACTOR = ${ fillfactor }</#if><#if parallel_workers?? && parallel_workers != '' >,
+parallel_workers = ${ parallel_workers }</#if><#if toast_tuple_target?? && toast_tuple_target != ''>,
+toast_tuple_target = ${ data.toast_tuple_target }</#if><#if autovacuum_enabled?? && (autovacuum_enabled == 't' || autovacuum_enabled == 'f') >,
+autovacuum_enabled = <#if autovacuum_enabled == 't' >TRUE<#else >FALSE</#if></#if><#if toast_autovacuum_enabled?? && (toast_autovacuum_enabled == 't' || toast_autovacuum_enabled == 'f')  >,
+toast.autovacuum_enabled = <#if toast_autovacuum_enabled == 't' >TRUE<#else >FALSE</#if>
+</#if><#if autovacuum_custom!false && vacuum_table?size gt 0 >
+<#list vacuum_table as opt ><#if opt.name?? && opt.value?? >
+,
+${opt.name} = ${opt.value}</#if>
+</#list></#if><#if toast_autovacuum!false && vacuum_toast?size gt 0 >
+<#list vacuum_toast as opt ><#if opt.name?? && opt.value?? >
+,
+toast.${opt.name} = ${opt.value}</#if>
+</#list></#if>
+<#if spcname?? >
+)
+TABLESPACE ${spcname };
+<#else>
+);
+</#if>
+<#if description?? >
+COMMENT ON TABLE ${schema}.${name}
+IS '${description}';
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.description?? >
+COMMENT ON COLUMN ${schema}.${name}.${c.name}
+IS '${c.description}';
+</#if>
+</#list>
+</#if>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=primary_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=unique_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=foreign_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=check_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=exclude_constraint/>
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/properties.ftl
new file mode 100644
index 00000000000..bc6c05bd6d4
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/table/11_plus/properties.ftl
@@ -0,0 +1,92 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str,
+(CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE
+(SELECT sp.spcname FROM pg_catalog.pg_database dtb
+JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
+WHERE dtb.oid = ${ did?c }::oid)
+END) as spcname,
+(CASE rel.relreplident
+WHEN 'd' THEN 'default'
+WHEN 'n' THEN 'nothing'
+WHEN 'f' THEN 'full'
+WHEN 'i' THEN 'index'
+END) as replica_identity,
+(select nspname FROM pg_catalog.pg_namespace WHERE oid = ${scid?c}::oid ) as schema,
+pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids, rel.relkind,
+(CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned,
+rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey,
+EXISTS(select 1 FROM pg_catalog.pg_trigger
+JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger'
+JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
+WHERE tgrelid=rel.oid) AS isrepl,
+(SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
+(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
+pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname)
+ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS coll_inherits,
+(SELECT count(*)
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
+(CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'toast_tuple_target=([0-9]*)') AS toast_tuple_target,
+(substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age,
+(substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
+rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype,
+CASE WHEN typ.typname IS NOT NULL THEN (select pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace WHERE oid = ${scid?c}::oid )||'.'||pg_catalog.quote_ident(typ.typname) ELSE typ.typname END AS typname,
+typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy,
+(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
+(SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels,
+(CASE WHEN rel.oid <= ${ datlastsysoid?c}::oid THEN true ElSE false END) AS is_sys_table
+-- Added for partition table
+<#if tid?? >, (CASE WHEN rel.relkind = 'p' THEN pg_catalog.pg_get_partkeydef(${ tid?c }::oid) ELSE '' END) AS partition_scheme </#if>
+FROM pg_catalog.pg_class rel
+LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
+LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid
+LEFT JOIN pg_catalog.pg_type typ ON rel.reloftype=typ.oid
+WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = ${ scid?c }::oid
+AND NOT rel.relispartition
+<#if tid?? >  AND rel.oid = ${ tid?c }::oid </#if>
+ORDER BY rel.relname;