문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
기술문서:레퍼런스:쿼리:기본:일련번호_생성 [2026/06/19 10:53] carlito76 |
기술문서:레퍼런스:쿼리:기본:일련번호_생성 [2026/08/25 17:10] (현재) carlito76 |
||
|---|---|---|---|
| 줄 18: | 줄 18: | ||
| ===== MySQL/ | ===== MySQL/ | ||
| + | ==== 자동 증가 ==== | ||
| <sxh sql; gutter: true; title: DDL;> | <sxh sql; gutter: true; title: DDL;> | ||
| /* | /* | ||
| 줄 29: | 줄 30: | ||
| <sxh sql; gutter: true; title: DML;> | <sxh sql; gutter: true; title: DML;> | ||
| - | -- 자동 증가 | ||
| INSERT INTO ex_serial_number (value) VALUES (' | INSERT INTO ex_serial_number (value) VALUES (' | ||
| + | </ | ||
| + | |||
| + | ==== 시퀀스 ==== | ||
| + | <sxh sql; gutter: true; title: DDL;> | ||
| + | CREATE TABLE ex_serial_number ( | ||
| + | sn BIGINT NOT NULL PRIMARY KEY, | ||
| + | value VARCHAR(100) NOT NULL | ||
| + | ); | ||
| + | |||
| + | /* | ||
| + | MariaDB 10.3 이상 | ||
| + | */ | ||
| + | CREATE SEQUENCE ex_serial_number_seq | ||
| + | START WITH 1 | ||
| + | INCREMENT BY 1 | ||
| + | MINVALUE 1 | ||
| + | MAXVALUE 9223372036854775806 -- 최댓값은 Signed BIGINT - 1 | ||
| + | NOCYCLE | ||
| + | CACHE 20 | ||
| + | ; | ||
| + | </ | ||
| + | |||
| + | <sxh sql; gutter: true; title: DML;> | ||
| + | INSERT INTO ex_serial_number (sn, value) VALUES (NEXT VALUE FOR ex_serial_number_seq, | ||
| + | -- INSERT INTO ex_serial_number (sn, value) VALUES (NEXTVAL(' | ||
| </ | </ | ||
| ===== MSSQL ===== | ===== MSSQL ===== | ||
| + | ==== 자동 증가 ==== | ||
| <sxh sql; gutter: true; title: DDL;> | <sxh sql; gutter: true; title: DDL;> | ||
| /* | /* | ||
| 줄 45: | 줄 71: | ||
| <sxh sql; gutter: true; title: DML;> | <sxh sql; gutter: true; title: DML;> | ||
| - | -- 자동 증가 | ||
| INSERT INTO ex_serial_number (value) VALUES (' | INSERT INTO ex_serial_number (value) VALUES (' | ||
| </ | </ | ||
| - | ===== Oracle/ | + | ==== 시퀀스 |
| <sxh sql; gutter: true; title: DDL;> | <sxh sql; gutter: true; title: DDL;> | ||
| - | /* | ||
| - | Oracle 8i 이상/ | ||
| - | */ | ||
| CREATE TABLE ex_serial_number ( | CREATE TABLE ex_serial_number ( | ||
| - | sn NUMBER | + | sn BIGINT |
| value VARCHAR(100) NOT NULL | value VARCHAR(100) NOT NULL | ||
| ); | ); | ||
| + | /* | ||
| + | MSSQL 2012 이상 | ||
| + | */ | ||
| CREATE SEQUENCE ex_serial_number_seq | CREATE SEQUENCE ex_serial_number_seq | ||
| + | AS BIGINT | ||
| START WITH 1 | START WITH 1 | ||
| INCREMENT BY 1 | INCREMENT BY 1 | ||
| MINVALUE 1 | MINVALUE 1 | ||
| - | MAXVALUE | + | MAXVALUE |
| - | NOCYCLE | + | NO CYCLE |
| CACHE 20 | CACHE 20 | ||
| - | NOORDER | ||
| ; | ; | ||
| </ | </ | ||
| <sxh sql; gutter: true; title: DML;> | <sxh sql; gutter: true; title: DML;> | ||
| - | -- 시퀀스 | + | INSERT INTO ex_serial_number (sn, value) VALUES (NEXT VALUE FOR ex_serial_number_seq, |
| - | INSERT INTO ex_serial_number (sn, value) VALUES (ex_serial_number_seq.NEXTVAL, ' | + | |
| </ | </ | ||
| + | ===== Oracle/ | ||
| + | ==== 자동 증가 ==== | ||
| <sxh sql; gutter: true; title: DDL;> | <sxh sql; gutter: true; title: DDL;> | ||
| -- Oracle 12c 이상 | -- Oracle 12c 이상 | ||
| 줄 84: | 줄 110: | ||
| <sxh sql; gutter: true; title: DML;> | <sxh sql; gutter: true; title: DML;> | ||
| - | -- 자동 증가 | ||
| INSERT INTO ex_serial_number (value) VALUES (' | INSERT INTO ex_serial_number (value) VALUES (' | ||
| + | </ | ||
| + | |||
| + | ==== 시퀀스 ==== | ||
| + | <sxh sql; gutter: true; title: DDL;> | ||
| + | CREATE TABLE ex_serial_number ( | ||
| + | sn NUMBER NOT NULL PRIMARY KEY, | ||
| + | value VARCHAR(100) NOT NULL | ||
| + | ); | ||
| + | |||
| + | /* | ||
| + | Oracle 8i 이상/ | ||
| + | */ | ||
| + | CREATE SEQUENCE ex_serial_number_seq | ||
| + | START WITH 1 | ||
| + | INCREMENT BY 1 | ||
| + | MINVALUE 1 | ||
| + | MAXVALUE 9999999999999999999999999999 -- 최댓값은 양의 정수 28자리 | ||
| + | NOCYCLE | ||
| + | CACHE 20 | ||
| + | NOORDER | ||
| + | ; | ||
| + | </ | ||
| + | |||
| + | <sxh sql; gutter: true; title: DML;> | ||
| + | INSERT INTO ex_serial_number (sn, value) VALUES (ex_serial_number_seq.NEXTVAL, | ||
| </ | </ | ||
| ===== PostgreSQL ===== | ===== PostgreSQL ===== | ||
| + | ==== 자동 증가 ==== | ||
| <sxh sql; gutter: true; title: DDL;> | <sxh sql; gutter: true; title: DDL;> | ||
| /* | /* | ||
| 줄 108: | 줄 159: | ||
| <sxh sql; gutter: true; title: DML;> | <sxh sql; gutter: true; title: DML;> | ||
| - | -- 자동 증가 | ||
| INSERT INTO ex_serial_number (value) VALUES (' | INSERT INTO ex_serial_number (value) VALUES (' | ||
| + | </ | ||
| + | |||
| + | ==== 시퀀스 ==== | ||
| + | <sxh sql; gutter: true; title: DDL;> | ||
| + | CREATE TABLE ex_serial_number ( | ||
| + | sn BIGINT NOT NULL PRIMARY KEY, | ||
| + | value VARCHAR(100) NOT NULL | ||
| + | ); | ||
| + | |||
| + | /* | ||
| + | PostgreSQL 6.0 이상 | ||
| + | */ | ||
| + | CREATE SEQUENCE ex_serial_number_seq | ||
| + | START WITH 1 | ||
| + | INCREMENT BY 1 | ||
| + | MINVALUE 1 | ||
| + | MAXVALUE 9223372036854775806 -- 최댓값은 Signed BIGINT - 1 | ||
| + | NO CYCLE | ||
| + | CACHE 20 | ||
| + | ; | ||
| + | |||
| + | /* | ||
| + | PostgreSQL 10.0 이상 | ||
| + | */ | ||
| + | CREATE SEQUENCE ex_serial_number_seq | ||
| + | AS BIGINT | ||
| + | START WITH 1 | ||
| + | INCREMENT BY 1 | ||
| + | MINVALUE 1 | ||
| + | MAXVALUE 9223372036854775806 -- 최댓값은 Signed BIGINT - 1 | ||
| + | NO CYCLE | ||
| + | CACHE 20 | ||
| + | ; | ||
| + | </ | ||
| + | |||
| + | <sxh sql; gutter: true; title: DML;> | ||
| + | INSERT INTO ex_serial_number (sn, value) VALUES (NEXTVAL(' | ||
| </ | </ | ||
| {{tag>" | {{tag>" | ||