CREATE TABLE IF NOT EXISTS建表语句,在达梦中是怎么实现?

已邀请:

本身达梦数据库不支持这种语法,不过可以通过函数绕过:


declare
vl_num number(8);
SQL_create varchar2(1024);
begin
select count(*) into vl_num from dba_tables where table_name='TestTB';
if ( vl_num = 0 ) then
SQL_create := 'create table TestTB(ID int,Name varchar(20) default('' ''))';
execute immediate SQL_create;
end if;
end;

要回复问题请先登录注册