Last active
August 5, 2016 05:20
-
-
Save 64lines/d24b797e2c637da0a4dc to your computer and use it in GitHub Desktop.
Clustered tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creating clusters | |
CREATE CLUSTER CLS_Persona_Ciudad (CIUDAD_ID NUMBER(20)); | |
CREATE TABLE CIUDAD_REG | |
( | |
CIUDAD_ID NUMBER(20) NOT NULL PRIMARY KEY, | |
NOMBRE VARCHAR2(20 BYTE) | |
) CLUSTER CLS_Persona_Ciudad (CIUDAD_ID); | |
CREATE TABLE PERSONA_REG | |
( | |
PERSONA_ID NUMBER(20) NOT NULL PRIMARY KEY, | |
CEDULA VARCHAR2(20 BYTE), | |
NOMBRE VARCHAR2(20 BYTE), | |
APELLIDO VARCHAR2(20 BYTE), | |
CIUDAD_ID NUMBER(20) REFERENCES CIUDAD_REG | |
) CLUSTER CLS_Persona_Ciudad (CIUDAD_ID); | |
-- Create index | |
CREATE INDEX IDX_PERSONA_CIUDAD ON CLUSTER CLS_Persona_Ciudad; | |
-- Bulk con 20000 inserts (Cargar en memoria y luego cargar en la tabla) | |
DECLARE | |
BEGIN | |
FOR i IN 1..10000 LOOP | |
INSERT INTO PERSONA_REG values (i, i, 'Carlos', 'Giraldo', dbms_random.value(1, 5)); | |
END LOOP; | |
COMMIT; | |
END; | |
select c.nombre from CIUDAD_REG c, PERSONA_REG p where p.ciudad_id = c.ciudad_id and p.persona_id=107; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment