We have created a awesome theme
Far far away,behind the word mountains, far from the countries

INFO ½ÇÀü DB¸ðµ¨¸µ°ú SQL°úÁ¤

INFO

½ÇÀü DB¸ðµ¨¸µ°ú SQL°úÁ¤
Á¶È¸¼ö 1064
Á¦¸ñ Chapter9_ä¹ø : ¿¹Á¦¸ðÀ½1
ÀÛ¼ºÀÚ °ü¸®ÀÚ
ÀÛ¼ºÀÏÀÚ 2021-12-03

¡á¿¹ 9_1_1  ||  SEQUENCE »ý¼º ¿¹
CREATE SEQUENCE INSA_SEQ
MINVALUE 1
MAXVALUE 33
INCREMENT BY 3
START WITH 28
NOCACHE
NOORDER
NOCYCLE
;



¡á¿¹ 9_1_2  ||  SEQUENCE »ç¿ë ¿¹
INSERT INTO INSA (SABUN, NAME, ENG_NAME, HP, JOIN_GBN_CODE)
VALUES (INSA_SEQ.NEXTVAL, 'È«±æµ¿', 'HONG', '010-1234-5678', 'RGL');

INSERT INTO INSA (SABUN, NAME, ENG_NAME, HP, JOIN_GBN_CODE)
VALUES (INSA_SEQ.NEXTVAL, 'À̼ø½Å', 'LEGEND', '010-1234-1234', 'RGL');

SELECT ROWNUM,T1.*
FROM( SELECT SABUN, NAME, ENG_NAME, HP, JOIN_GBN_CODE
         FROM INSA
         WHERE JOIN_GBN_CODE='RGL'
         ORDER BY SABUN DESC) T1
WHERE ROWNUM <= 2;



¡á¿¹ 9_1_3  ||  SEQUENCE »ç¿ë ¿¹
____CREATE TABLE____ INSA_1(
SEQ_NO NUMBER CONSTRAINT TEST_SEQ_NN NOT NULL,
SABUN VARCHAR2(10),
JOIN_DAY DATE,
CONSTRAINT INSA1_PK PRIMARY KEY(SABUN)
);

CREATE SEQUENCE INSA_SEQ1
MINVALUE 1
MAXVALUE 10
INCREMENT BY 2
START WITH 2
CYCLE
;

INSERT INTO TEST_SEQ VALUES(INSA_SEQ1.NEXTVAL, :SABUN,  SYSDATE);



¡á¿¹ 9_1_4  ||  INSA_SEQ ¼öÁ¤
ALTER SEQUENCE INSA_SEQ
INCREMENT BY 2
MAXVALUE 9999999999;



¡á¿¹ 9_1_5  ||  INSA_SEQ ¼öÁ¤ ÈÄ Àû¿ë
INSERT INTO INSA (SABUN, NAME, ENG_NAME, HP, JOIN_GBN_CODE)
VALUES (INSA_SEQ.NEXTVAL, '¹ÚÁØÇü', 'LIM', '010-1111-2222', 'RGL');



¡á¿¹ 9_1_6  ||  SEQUENCE »èÁ¦
DROP SEQUENCE SEQUENCE_NAME;
DROP SEQUNECE INSA_SQL;



¡á¿¹ 9_1_7  ||  SEQUENCE È®ÀÎ
SELECT  *  FROM  USER_SEQUENCES;

÷ºÎÆÄÀÏ