create or replace procedure createtable(tname in varchar2)
is
SQLTEXT varchar2(400);
v_createsql varchar2(400);
v_dropsql varchar2(100);
v_count number(9);
begin
SQLTEXT := 'grant create any table to newsname'; --newsname为数据库用户名,这里需要给他创建表的权限
EXECUTE IMMEDIATE SQLTEXT;
v_createsql:='create table '||tname||'(
a number(8) primary key,
b varchar2(20))';
v_dropsql:='drop table '||tname||' cascade constraints';
select count(*) into v_count from user_tables where table_name=upper(tname);
if v_count>0 then
execute immediate v_dropsql;
commit;
end if;
execute immediate v_createsql;
commit;
end;
用oracle存储过程创建表
最新推荐文章于 2024-11-29 14:12:37 发布
本文介绍了一个使用PL/SQL创建表格的过程,包括权限授予、创建SQL语句、检查表是否存在并进行相应操作。
1193

被折叠的 条评论
为什么被折叠?



