Last active
December 29, 2022 14:52
-
-
Save TyeolRik/bc4e20212fba045ed91254ef47a9bb4f to your computer and use it in GitHub Desktop.
[Oracle] Use list using VARRAY data type.
This file contains 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
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
단 이렇게 하면,
CREATE TYPE SUBUSERS AS VARRAY(1000) OF SUBUSER;
문장에서 VARRAY 의 크기 할당 때문에 쓸데없이 낭비되는 디스크 자원이 많아질 것으로 예상됨.그러므로 쓰지 말자.