jp.co.tis.gsp.tools.db.template.h2.createTable.ftl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gsp-dba-maven-plugin Show documentation
Show all versions of gsp-dba-maven-plugin Show documentation
To automate the routine work of the DBA, it is a tool to be able to concentrate on the data modeling work.
<#-- IDENTITY型に対してALTER TABLEでPKを付与しようとするとエラーが発生するため、PKは一律CREATE TABLEで付与する -->
CREATE TABLE <#if entity.schema?has_content>${entity.schema}.#if>${entity.name} (
<#foreach column in entity.columnList>
${column.name} ${column.dataType}<#if column.length != 0>(${column.length}<#if column.scale!=0>,${column.scale}#if>)#if><#if column.isArray()> ARRAY#if><#if !column.isNullable()> NOT NULL#if><#if column.defaultValue?has_content> DEFAULT ${column.defaultValue}#if><#if column_has_next>,<#else><#if entity.havePrimaryKey()>,#if>#if>
#foreach>
<#if entity.havePrimaryKey()>
<#assign isFirst = "true" />
PRIMARY KEY (<#foreach column in entity.columnList><#if column.isPrimaryKey()><#if isFirst!="true">, #if>${column.name}<#assign isFirst = "false" />#if>#foreach>)
#if>
);
<#if entity.label?has_content>
COMMENT ON table <#if entity.schema?has_content>${entity.schema}.#if>${entity.name} is '${entity.label}';
#if>
<#foreach column in entity.columnList>
<#if column.label?has_content>
COMMENT ON column <#if entity.schema?has_content>${entity.schema}.#if>${entity.name}.${column.name} is '${column.label}';
#if>
#foreach>