123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- --指标基础信息表
- CREATE TABLE ETA_API_QUOTA_INFO
- (
- quote_id NUMBER NOT NULL,
- edb_info_id NUMBER NOT NULL,
- edb_code VARCHAR2(200) NOT NULL, -- 假设最大长度为255,可根据实际需求调整
- edb_name VARCHAR2(255) NOT NULL,
- UNIQUE_CODE VARCHAR2(60) NOT NULL,-- 假设最大长度为255,可根据实际需求调整
- unit VARCHAR2(100) NOT NULL, -- 假设最大长度为100,可根据实际需求调整
- frequency VARCHAR2(30) NOT NULL, -- 假设最大长度为50,可根据实际需求调整
- start_date DATE NOT NULL,
- end_date DATE NOT NULL,
- last_date DATE NOT NULL,
- classify_id NUMBER NOT NULL,
- source NUMBER(10) NOT NULL,
- source_name VARCHAR2(120) NOT NULL, -- 假设最大长度为255,可根据实际需求调整
- no_update NUMBER(1) DEFAULT 0 NOT NULL, -- 假设为布尔值,用数字1表示是,0表示否
- is_delete NUMBER(1) DEFAULT 0 NOT NULL, -- 假设为布尔值,用数字1表示是,0表示否
- is_quality NUMBER(1) DEFAULT 0 NOT NULL, -- 假设为布尔值,用数字1表示是,0表示否
- data_create_time NUMBER DEFAULT 0, -- 如果是时间戳,需指定精度;若为日期类型,请改为 DATE
- data_update_time NUMBER DEFAULT 0, -- 如果是时间戳,需指定精度;若为日期类型,请改为 DATE
- ht_unique_code VARCHAR2(255), -- 假设最大长度为255,可根据实际需求调整
- CONSTRAINT ETA_API_QUOTA_INFO_PK PRIMARY KEY (quote_id)
- );
- CREATE SEQUENCE seq_eta_api_quota_info
- START WITH 1
- INCREMENT BY 1
- NOMAXVALUE;
- CREATE OR REPLACE TRIGGER trg_eta_api_quota_info_insert
- BEFORE INSERT ON eta_api_quota_info
- FOR EACH ROW
- BEGIN
- SELECT seq_eta_api_quota_info.NEXTVAL INTO :new.quota_id FROM dual;
- END;
- /
- CREATE INDEX ETA_API_QUOTA_UNIQUE_CODE ON ETA_API_QUOTA_INFO ("UNIQUE_CODE", "LATEST_DATE")
- --指标明细数据表
- CREATE TABLE ETA_API_QUOTA_DATA
- (
- data_id NUMBER NOT NULL,
- unique_code VARCHAR2(60) NOT NULL,
- value NUMBER NOT NULL, -- 假设最大长度为255,可根据实际需求调整
- data_time DATE NOT NULL,
- update_time TIMESTAMP (6) NOT NULL,
- is_delete NUMBER(1) DEFAULT 0 NOT NULL, -- 假设为布尔值,用数字1表示是,0表示否
- is_quality NUMBER(1) DEFAULT 0 NOT NULL, -- 假设为布尔值,用数字1表示是,0表示否
- data_create_time NUMBER, -- 如果是时间戳,需指定精度;若为日期类型,请改为 DATE
- data_update_time NUMBER, -- 如果是时间戳,需指定精度;若为日期类型,请改为 DATE
- ht_unique_code VARCHAR2(255) ,
- CONSTRAINT ETA_API_QUOTA_DATA_PK PRIMARY KEY (data_id),
- );
- CREATE SEQUENCE seq_eta_api_quota_data
- START WITH 1
- INCREMENT BY 1
- NOMAXVALUE;
- CREATE OR REPLACE TRIGGER trg_eta_api_quota_data_insert
- BEFORE INSERT ON eta_api_quota_data
- FOR EACH ROW
- BEGIN
- SELECT seq_eta_api_quota_data.NEXTVAL INTO :new.data_id FROM dual;
- END;
- /
- CREATE UNIQUE INDEX ETA_API_DATA_UNIQUE_CODE ON ETA_API_QUOTA_DATA ("UNIQUE_CODE", "DATA_TIME", "IS_DELETE")
- CREATE INDEX IDX_UNIQUE_CODE_DATA_TIME ON ETA_API_QUOTA_DATA ("UNIQUE_CODE", "DATA_TIME" DESC)
- CREATE INDEX ETA_API_DATA_UNIQUE_CODE_INDEX ON ETA_API_QUOTA_DATA ("UNIQUE_CODE")
- /*
- * 辅助表,用于建立指标与指标分类之间的映射关系
- */
- CREATE SEQUENCE SEQ_ETA_CLASSIFY_INDEX_MAPPING
- START WITH 1
- INCREMENT BY 1
- NOMAXVALUE;
- CREATE OR REPLACE TRIGGER trg_SEQ_ETA_CLASSIFY_insert
- BEFORE INSERT ON t_eta_CLASSIFY_INDEX_MAPPINGr
- FOR EACH ROW
- BEGIN
- SELECT SEQ_ETA_CLASSIFY_INDEX_MAPPING.NEXTVAL INTO :new.id FROM dual;
- END;
- /**
- 修改已更新的指标的频度单位
- */
- select * from T_DAMP_DW_INDEX where INDEX_CODE in (
- select INDEX_CODE from T_DAMP_DW_INDEX_LINK where LINK_CODE like 'ETA%') and FREQUENCY like '%度'
- UPDATE T_DAMP_DW_INDEX
- SET FREQUENCY = REPLACE(FREQUENCY, '度', '')
- WHERE INDEX_CODE IN (
- SELECT INDEX_CODE
- FROM T_DAMP_DW_INDEX_LINK
- WHERE LINK_CODE LIKE 'ETA%'
- )
- AND FREQUENCY LIKE '%度%';
|