createTableTemplate.ftl.svn-base
1.07 KB
-- Create table
create table ${tableName}
(
<#list columnlist as clist>
${clist.columnName} ${clist.columnSQLType}<#if clist.columnSize?exists>${clist.columnSize}</#if><#if clist.columnDefaults?exists && clist.columnDefaults != '' && clist.columnDefaults != 'null'> default ${clist.columnDefaults}</#if><#if !clist.nullable> not null</#if><#if clist_has_next>,</#if>
</#list>
);
<#if tableRemarks?exists>
-- Add comments to the table
comment on table ${tableName} is '${tableRemarks}';
</#if>
-- Add comments to the columns
<#list columnlist as clist>
<#if clist.columnRemarks?exists && clist.columnRemarks != clist.columnName>
comment on column ${tableName}.${clist.columnName} is '${clist.columnRemarks}';
</#if>
</#list>
<#if tablePk?exists>
-- Create index
CREATE UNIQUE INDEX PK_${tableName} ON ${tableName}(${tablePk});
ALTER TABLE ${tableName} ADD
PRIMARY KEY (${tablePk})
USING INDEX PK_${tableName};
</#if>
-- Create sequence
create sequence SEQ_${tableName}<#if tableName?length lt 24>_PK</#if>
minvalue 1
maxvalue 99999999999999999
start with 1
increment by 1
cache 20;