oracle 语句块中创建表

declare
  l_flag int;
begin
  select count(*) into l_flag from user_tables where table_name = upper('ops_zd_status');

  IF l_flag = 0 then
  execute immediate 'CREATE TABLE ops_zd_status(
    code varchar2(4) NOT NULL,
    name varchar2(64) NULL,
    py_code varchar2(50) NULL,
    wb_code varchar2(50) NULL,
    d_code varchar2(25) NULL,
   CONSTRAINT PK_ops_zd_status PRIMARY KEY
  (
    code
  )
  )'; 
  end if;

END;

posted @ 2014-05-04 14:44  忆韩  阅读(449)  评论(0编辑  收藏  举报