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;