declare v_sql varchar2(5000); v_iscount number;
begin
-- 检查表是否存在
select count(1) into v_iscount from user_tables where table_name = upper('${tableName}');
-- 不存在执行DDL语句
if v_iscount = 0 then
-- 执行建表语句
v_sql := 'create table table_name
(
col_name col_type
)';
execute immediate v_sql;
-- 建主键
v_sql := 'alter table table_name add constraint PK_NAME primary key (col_name)';
execute immediate v_sql;
-- 建索引语句
v_sql := 'create index index_name on table_name(col_name)';
execute immediate v_sql;
end if;
end;
标签:表示,name,--,sql,Oracle,table,iscount,动态,col
From: https://www.cnblogs.com/codechange/p/17482089.html