日期:2014-05-17  浏览次数:21033 次

SQL文~求高手来~~~~~~~~~~~~~~~~~~~~~~
现在有两个表
一个主表是 考勤信息表
SQL code

CREATE TABLE HIPS_HR.HR_WORK_ATTEND
(
    PERSONNEL_ID                   VARCHAR2(10) NOT NULL,
    FREQUENCY                      VARCHAR2(10) NOT NULL,
    WORKDAY                        VARCHAR2(8) NOT NULL,
    WORKTIME                       DATE,
    CLOSETIME                      DATE,
    OVERTIMEFLG                    CHAR(1) NOT NULL,
    UPDATE_TIME                    DATE,
    UPDATE_USERID                  VARCHAR2(20),
    CREATE_TIME                    DATE,
    CREATE_USERID                  VARCHAR2(20),
    EXCLUSIVEKEY                   VARCHAR2(100),
    CONSTRAINT WORK_ATTEND_KEY PRIMARY KEY (PERSONNEL_ID, WORKDAY, FREQUENCY) USING INDEX
        PCTFREE 10
        INITRANS 2
        MAXTRANS 255
        TABLESPACE USERS
        STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
        LOGGING
)
PCTFREE 10
MAXTRANS 255
TABLESPACE USERS
STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
NOCACHE
LOGGING
/
COMMENT ON TABLE HIPS_HR.HR_WORK_ATTEND IS '考勤信息表'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.PERSONNEL_ID IS '员工ID'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.FREQUENCY IS '班次'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.WORKDAY IS '工作日'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.WORKTIME IS '上班时间'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.CLOSETIME IS '下班时间'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.OVERTIMEFLG IS '是否加班  1:是  0:不是'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.UPDATE_TIME IS '更新时间'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.UPDATE_USERID IS '更新者'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.CREATE_TIME IS '创建时间'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.CREATE_USERID IS '创建者'
/
COMMENT ON COLUMN HIPS_HR.HR_WORK_ATTEND.EXCLUSIVEKEY IS '排他键'
/




还有一个是请假表
SQL code

CREATE TABLE HIPS_HR.HR_LEAVE
(
    LEAVE_ID                       VARCHAR2(15) NOT NULL,
    PERSONNEL_ID                   VARCHAR2(50),
    FREQUENCY                      VARCHAR2(10),
    LEAVE_DATE                     DATE,
    LEAVE_LENGTH_DAY               NUMBER(10,0),
    LEAVE_LENGTH_HOUR              NUMBER(10,0),
    LEAVE_LENGTH_MIN               NUMBER(10,0),
    LEAVE_KSSJ                     DATE,
    LEAVE_JSSJ                     DATE,
    LEAVE_TYPE                     VARCHAR2(5),
    LEAVE_REASON                   VARCHAR2(200),
    STATUS                         VARCHAR2(200),
    UPDATE_TIME                    DATE,
    UPDATE_USERID                  VARCHAR2(20),
    CREATE_TIME                    DATE,
    CREATE_USERID                  VARCHAR2(20),
    EXCLUSIVEKEY                   VARCHAR2(100) NOT NULL,
    CONSTRAINT HR_LEAVE_PK PRIMARY KEY (LEAVE_ID) USING INDEX
        PCTFREE 10
        INITRANS 2
        MAXTRANS 255
        TABLESPACE USERS
        STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
        LOGGING
)
PCTFREE 10
MAXTRANS 255
TABLESPACE USERS
STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
NOCACHE
LOGGING
/
COMMENT ON TABLE HIPS_HR.HR_LEAVE IS '员工请假表'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_ID IS '请假编号'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.PERSONNEL_ID IS '用户ID'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.FREQUENCY IS '班次'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_DATE IS '请假日期'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_LENGTH_DAY IS '请假时长(天)'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_LENGTH_HOUR IS '请假时长(小时)'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_LENGTH_MIN IS '请假时长(分钟)'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_KSSJ IS '请假开始时间'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.LEAVE_JSSJ IS '请假结束时间'
/
COMMENT ON COLUMN HIPS_HR.HR_LEAVE.