﻿--------------------------------------------------------
--  DDL for Table HIS_ALARM_DATA
--------------------------------------------------------

  CREATE TABLE "MIRLE"."HIS_ALARM_DATA" 
  (	
	  "ALARM_CODE" VARCHAR2(10 CHAR), 
	  "ALARM_TYPE" VARCHAR2(3 CHAR), 
	  "START_TIME" TIMESTAMP (6), 
	  "ALARM_DESC" VARCHAR2(50 CHAR), 
	  "SOFTWARE_ID" VARCHAR2(7 CHAR), 
	  "TASK_ID" VARCHAR2(16 CHAR), 
	  "VEHICLE_ID" VARCHAR2(16 CHAR), 
	  "END_TIME" TIMESTAMP (6), 
	  "PROGRAM_NAME" VARCHAR2(30 CHAR),
	  "HISTORY_TIME" TIMESTAMP (6) DEFAULT systimestamp
  )
  SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 
  NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "SYSTEM" ;

  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."HISTORY_TIME" IS '寫入時間';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."ALARM_CODE" IS '異常代碼';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."ALARM_TYPE" IS '異常類別';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."START_TIME" IS '起始時間';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."ALARM_DESC" IS '異常敘述';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."SOFTWARE_ID" IS '軟體編號';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."VEHICLE_ID" IS '設備編號';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."TASK_ID" IS '任務編號';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."END_TIME" IS '結束時間';
  COMMENT ON COLUMN "MIRLE"."HIS_ALARM_DATA"."PROGRAM_NAME" IS '程式名稱';

--------------------------------------------------------
--  DDL for Index HIS_ALARM_DATA_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "MIRLE"."HIS_ALARM_DATA_PK" ON "MIRLE"."HIS_ALARM_DATA" ("HISTORY_TIME", "ALARM_CODE", "ALARM_TYPE", "START_TIME") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "SYSTEM" ;

--------------------------------------------------------
--  Constraints for Table HIS_ALARM_DATA
--------------------------------------------------------

  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("HISTORY_TIME" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("ALARM_CODE" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("ALARM_TYPE" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("START_TIME" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("SOFTWARE_ID" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("TASK_ID" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("END_TIME" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" MODIFY ("PROGRAM_NAME" NOT NULL ENABLE);
  ALTER TABLE "MIRLE"."HIS_ALARM_DATA" ADD CONSTRAINT "HIS_ALARM_DATA_PK" PRIMARY KEY ("HISTORY_TIME", "ALARM_CODE", "ALARM_TYPE", "START_TIME")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "SYSTEM"  ENABLE;