-- =============================================
-- Oracle version for zgwl_end.sql
-- Execute with: sqlplus developer/dev123@localhost/XEPDB1 @zgwl_end_oracle.sql
-- =============================================

WHENEVER SQLERROR EXIT SQL.SQLCODE;

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

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

CREATE TABLE BIZ_STUDENT (
    ID NUMBER(19) NOT NULL,
    STUDENT_NO VARCHAR2(64 CHAR) NOT NULL,
    STUDENT_NAME VARCHAR2(64 CHAR) NOT NULL,
    GENDER VARCHAR2(16 CHAR) NOT NULL,
    AGE NUMBER(10) NOT NULL,
    PHONE VARCHAR2(32 CHAR),
    ADDRESS VARCHAR2(255 CHAR),
    CREATE_DT TIMESTAMP(6),
    UPDATE_DT TIMESTAMP(6),
    CREATE_BY VARCHAR2(64 CHAR),
    UPDATE_BY VARCHAR2(64 CHAR),
    CONSTRAINT PK_BIZ_STUDENT PRIMARY KEY (ID),
    CONSTRAINT UK_BIZ_STUDENT_NO UNIQUE (STUDENT_NO)
);

COMMENT ON TABLE BIZ_STUDENT IS '学生表';
COMMENT ON COLUMN BIZ_STUDENT.ID IS '主键ID';
COMMENT ON COLUMN BIZ_STUDENT.STUDENT_NO IS '学号';
COMMENT ON COLUMN BIZ_STUDENT.STUDENT_NAME IS '姓名';
COMMENT ON COLUMN BIZ_STUDENT.GENDER IS '性别';
COMMENT ON COLUMN BIZ_STUDENT.AGE IS '年龄';
COMMENT ON COLUMN BIZ_STUDENT.PHONE IS '手机号';
COMMENT ON COLUMN BIZ_STUDENT.ADDRESS IS '地址';
COMMENT ON COLUMN BIZ_STUDENT.CREATE_DT IS '创建时间';
COMMENT ON COLUMN BIZ_STUDENT.UPDATE_DT IS '更新时间';
COMMENT ON COLUMN BIZ_STUDENT.CREATE_BY IS '创建人';
COMMENT ON COLUMN BIZ_STUDENT.UPDATE_BY IS '更新人';

INSERT INTO BIZ_STUDENT (ID, STUDENT_NO, STUDENT_NAME, GENDER, AGE, PHONE, ADDRESS, CREATE_DT, UPDATE_DT, CREATE_BY, UPDATE_BY) VALUES
(1925800000000000001, 'S2024001', '张三', '男', 20, '13800001111', '宁波市鄞州区', SYSTIMESTAMP, SYSTIMESTAMP, 'system', 'system');
INSERT INTO BIZ_STUDENT (ID, STUDENT_NO, STUDENT_NAME, GENDER, AGE, PHONE, ADDRESS, CREATE_DT, UPDATE_DT, CREATE_BY, UPDATE_BY) VALUES
(1925800000000000002, 'S2024002', '李四', '女', 21, '13800002222', '宁波市北仑区', SYSTIMESTAMP, SYSTIMESTAMP, 'system', 'system');
INSERT INTO BIZ_STUDENT (ID, STUDENT_NO, STUDENT_NAME, GENDER, AGE, PHONE, ADDRESS, CREATE_DT, UPDATE_DT, CREATE_BY, UPDATE_BY) VALUES
(1925800000000000003, 'S2024003', '王五', '男', 22, '13800003333', '宁波市镇海区', SYSTIMESTAMP, SYSTIMESTAMP, 'system', 'system');

CREATE SEQUENCE SEQ_BIZ_STUDENT
    START WITH 1925800000000000004
    INCREMENT BY 1
    NOCACHE
    NOCYCLE;
