create sequence Attachment_seq; DROP TABLE ATTACHMENT; create table Attachment ( AttachID INT not null, --自动增长号 AttachFilename VARCHAR2(250) null, --文件名 AttachFileSize INT not null, --文件大小 AttachMimeType VARCHAR2(70) null, --文件类型 AttachDesc VARCHAR2(250) null, --说明 AttachCreationIP VARCHAR2(20) not null, --上传的IP AttachCreationDate TIMESTAMP not null, --创建时间 AttachModifiedDate TIMESTAMP not null, --文件保存路径 ATTACHFILEPATH VARCHAR2 (250) NOT NULL, PRimary key (AttachID) ); create or replace trigger Attach_trig_autoinc before insert on Attachment for each row begin if (:new.AttachID is null) then select Attachment_seq.nextval into :new.AttachID from dual; end if; end;