Skip to content

Instantly share code, notes, and snippets.

@TyeolRik
Last active December 29, 2022 14:52
Show Gist options
  • Save TyeolRik/bc4e20212fba045ed91254ef47a9bb4f to your computer and use it in GitHub Desktop.
Save TyeolRik/bc4e20212fba045ed91254ef47a9bb4f to your computer and use it in GitHub Desktop.
[Oracle] Use list using VARRAY data type.
CREATE TYPE SUBUSER AS OBJECT (
ID VARCHAR2(200),
PERMISSIONS VARCHAR2(12)
);
CREATE TYPE SUBUSERS AS VARRAY(1000) OF SUBUSER; -- Nested Table type.
CREATE TABLE USER (
UID VARCHAR2(50),
SUBUSERS_COLUMN SUBUSERS -- An Instance of Nested Table
);
INSERT INTO USER VALUES ('1', SUBUSERS(SUBUSER('SUB1', 'A1'), SUBUSER('SUB2', 'A2')));
SELECT * FROM TABLE(SELECT SUBUSERS_COLUMN FROM USER WHERE UID = '1');
@TyeolRik
Copy link
Author

단 이렇게 하면, CREATE TYPE SUBUSERS AS VARRAY(1000) OF SUBUSER; 문장에서 VARRAY 의 크기 할당 때문에 쓸데없이 낭비되는 디스크 자원이 많아질 것으로 예상됨.

그러므로 쓰지 말자.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment