-- =============================================
-- SEAL_CONTRACT_LAUNCH_AR_PAPER 建表脚本 (Oracle)
-- 自动整理生成，已合并历史patch字段
-- 执行方式: sqlplus developer/dev123@localhost/XEPDB1 @SEAL_CONTRACT_LAUNCH_AR_PAPER.sql
-- =============================================

WHENEVER SQLERROR EXIT SQL.SQLCODE;

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SC_AR_PAPER';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_AR_PAPER CASCADE CONSTRAINTS';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

CREATE TABLE SEAL_CONTRACT_LAUNCH_AR_PAPER (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    ARCHIVES_NAME VARCHAR2(255 CHAR) NOT NULL,
    ARCHIVES_NUM VARCHAR2(50 CHAR) NOT NULL,
    ARCHIVES_TIME DATE NOT NULL,
    SORT_ORDER NUMBER(10) DEFAULT 1,
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SC_AR_PAPER PRIMARY KEY (ID)
);

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_AR_PAPER IS '合同归档纸质档案材料表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.ARCHIVES_NAME IS '档案名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.ARCHIVES_NUM IS '份数';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.ARCHIVES_TIME IS '归档时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.SORT_ORDER IS '排序号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_AR_PAPER.REMARK IS '备注';

CREATE INDEX IDX_SC_AR_PAPER_CTID ON SEAL_CONTRACT_LAUNCH_AR_PAPER (CONTRACT_ID);

CREATE SEQUENCE SEQ_SC_AR_PAPER
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    NOCYCLE
    CACHE 20
    NOORDER;

COMMIT;
