oracle11g自動分區使用

  1. 爲何使用自動分區?

在oracle11g以前,oracle是不支持自動分區功能的,這就可能致使咱們系統在運行一段時間以後,就須要看看分區是否建立或者寫觸發器進行建立分區,不然就會致使數據沒法入庫或者大量的數據所有都進入了默認分區。維護起來容易出錯並且複雜。但oracle11g出現了經過interval自動分區,這就使咱們系統在使用分區功能時更加自如。oracle

  1. 如何自動建立分區?

oracle自己提供了多種建立分區的功能,好比建立表的同時建立分區,或者建立好分區把數據導入進去,在或者在線定義分區,本文我主要介紹如何range模式下自動建立分區。編碼

  1. 建立分區具體實例(可直接運行)
CREATE TABLE "T_PART_TABLE"
   (	"ID" VARCHAR2(64),
	"PERSOID" NUMBER,
	"CODE" VARCHAR2(64),
	"NAME" VARCHAR2(64),
	"DEPT" VARCHAR2(64),
	"LOG_TIME" NUMBER,
	"LOG_TYPE" NUMBER,
	"CONTENT" VARCHAR2(1024),
	"RESULT" VARCHAR2(2),
	"SN" VARCHAR2(128),
	"DEPT_ID" NUMBER,
	"BLACK_FLAG" VARCHAR2(2 BYTE),
	"CREATE_TIME" Date)
	PARTITION BY RANGE (CREATE_TIME)  interval (numtodsinterval (1,'DAY'))
(
 PARTITION part_p180613 VALUES LESS THAN (TO_DATE('2018-6-13', 'yyyy-mm-dd'))
 );
   COMMENT ON COLUMN "T_PART_TABLE"."ID" IS '主鍵';

   COMMENT ON COLUMN "T_PART_TABLE"."PERSOID" IS 'id';

   COMMENT ON COLUMN "T_PART_TABLE"."CODE" IS '編碼';

   COMMENT ON COLUMN "T_PART_TABLE"."NAME" IS '姓名';

   COMMENT ON COLUMN "T_PART_TABLE"."DEPT" IS '部門';

   COMMENT ON COLUMN "T_PART_TABLE"."LOG_TIME" IS '日誌時間';

   COMMENT ON COLUMN "T_PART_TABLE"."LOG_TYPE" IS '類型 ';

   COMMENT ON COLUMN "T_PART_TABLE"."CONTENT" IS '內容';

   COMMENT ON COLUMN "T_PART_TABLE"."RESULT" IS '';

   COMMENT ON COLUMN "T_PART_TABLE"."SN" IS '證書sn';

   COMMENT ON COLUMN "T_PART_TABLE"."DEPT_ID" IS '部門id';
   CREATE UNIQUE INDEX "T_PART_TABLE_PK" ON "T_PART_TABLE" ("ID");
   ALTER TABLE "T_PART_TABLE" MODIFY ("ID" NOT NULL ENABLE);
   ALTER TABLE "T_PART_TABLE" ADD CONSTRAINT "T_PART_TABLE_PK" PRIMARY KEY ("ID") ENABLE;
相關文章
相關標籤/搜索