17,086
社区成员
发帖
与我相关
我的任务
分享
<select id="createTable" parameterType="java.util.Map">
<foreach collection="tableMap" index="key" item="value">
create table "${key}"(
<foreach collection="value" item="fields" separator=",">
<include refid="commonSql"></include>
</foreach>
)
<foreach collection="value" item="fields" separator=",">
<if test="fields.fieldIsAutoIncrement">
;CREATE SEQUENCE "${key}_${fields.fieldName}_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
</if>
<if test="fields.fieldIsKey">
;ALTER TABLE ${key} ADD CONSTRAINT PK_${key}_${fields.fieldName} PRIMARY KEY ("${fields.fieldName}")
</if>
<if test="fields.fieldIsUnique">
;CREATE UNIQUE INDEX IX_${key}_${fields.fieldName} ON ${key}("${fields.fieldName}")
</if>
</foreach>
</foreach>
</select>
<select id="createTable" parameterType="java.util.Map">
<foreach collection="tableMap" index="key" item="value">
begin
execute immediate
'create table "${key}"(
<foreach collection="value" item="fields" separator=",">
<include refid="commonSql"></include>
</foreach>
)';
<foreach collection="value" item="fields" separator=",">
<if test="fields.fieldIsAutoIncrement">
execute immediate
'CREATE SEQUENCE "${key}_${fields.fieldName}_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE';
</if>
<if test="fields.fieldIsKey">
execute immediate
'ALTER TABLE ${key} ADD CONSTRAINT PK_${key}_${fields.fieldName} PRIMARY KEY ("${fields.fieldName}")';
</if>
<if test="fields.fieldIsUnique">
execute immediate
'CREATE UNIQUE INDEX IX_${key}_${fields.fieldName} ON ${key}("${fields.fieldName}")';
</if>
</foreach>
end;
</foreach>
</select>
PLS-00103: 出现符号 "CREATE"在需要下列之一时:
( begin case declare
exit for goto if loop mod null pragma raise return select
update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
; bad SQL grammar []; nested exception is java.sql.SQLException: ORA-0655
而且就oracle不能用分号,MySQL和sqlserver都可以用