Loading

oracle 创建表同时添加注释

创建数据库表、添加注释的方法:

create table WARNINGRECORD
(
    RecordID varchar(36) primary key not null
);

comment on column WARNINGRECORD.RecordID is '告警编号';

现在想通过pl/sql语句块执行,代码如下:

declare tableExist number;
begin
    Select count(1) into tableExist from all_tables where TABLE_NAME='WARNINGRECORD';
    if tableExist>0 then
        execute immediate 'drop table WARNINGRECORD';
        return;
    end if;
    execute immediate 'CREATE TABLE WARNINGRECORD(RecordID varchar(36) PRIMARY KEY NOT NULL)';
    execute immediate 'COMMENT ON COLUMN WarningRecord.RecordID  IS ''告警编号''';
end;

 

posted @ 2017-06-02 10:14  guwei4037  阅读(9798)  评论(0编辑  收藏  举报