Compressing an Index

Compressing an Index example

CREATE TABLE ORDERS
   (ORDER_ID NUMBER NOT NULL ENABLE, 
	COURSE_ID NUMBER NOT NULL ENABLE, 
	STUDENT_ID NUMBER NOT NULL ENABLE, 
	ORDER_DATE DATE, 
	CONSTRAINT PK_ORDER_ID PRIMARY KEY (ORDER_ID)
	);

-- create Index Key Compression	
CREATE INDEX student_orders_idx 
   ON ORDERS (student_id, order_id)
   COMPRESS 1;

Output:

table ORDERS created.
index STUDENT_ORDERS_IDX created.

Check indexes

select INDEX_NAME, INDEX_TYPE, COMPRESSION
from USER_INDEXES
WHERE table_name='ORDERS';  

Output:

INDEX_NAME INDEX_TYPE COMPRESSION
PK_ORDER_ID NORMAL DISABLED
STUDENT_ORDERS_IDX NORMAL ENABLED