336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
Table Scheme
CREATE TABLE sequences ( name varchar(32), currval BIGINT UNSIGNED ) ENGINE=InnoDB;
procedure
DELIMITER $$
CREATE PROCEDURE `drop_sequence` (IN the_name text)
MODIFIES SQL DATA
DETERMINISTIC
BEGIN
DELETE FROM sequences WHERE name=the_name;
END;
DELIMITER $$
CREATE PROCEDURE `create_sequence`(IN the_name text)
MODIFIES SQL DATA
DETERMINISTIC
BEGIN
DELETE FROM sequences WHERE name=the_name;
INSERT INTO sequences VALUES (the_name, 0);
END;
function
DELIMITER $$
CREATE FUNCTION `currval` (the_name varchar(32))
RETURNS BIGINT UNSIGNED
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE ret BIGINT UNSIGNED;
SELECT currval INTO ret FROM sequences WHERE name=the_name limit 1;
RETURN ret;
END;
DELIMITER $$
CREATE FUNCTION `nextval`(the_name varchar(32))
RETURNS BIGINT UNSIGNED
MODIFIES SQL DATA
DETERMINISTIC
BEGIN
DECLARE ret BIGINT UNSIGNED;
UPDATE sequences SET currval=currval+1 WHERE name=the_name;
SELECT currval INTO ret FROM sequences WHERE name=the_name limit 1;
RETURN ret;
END;
사용 예)
call create_sequence('bar');
select nextval('bar'); #1
select currval('bar'); #1
select nextval('bar'); #2
select currval('bar'); #2
'DataBase' 카테고리의 다른 글
Partition Table(파티션 테이블) (0) | 2015.01.14 |
---|---|
select 구문으로 update 하기(오라클) (0) | 2014.09.24 |
Oracle 테이블 및 컬럼정보 조회 쿼리 (1) | 2014.02.27 |
mysql 에서 function, procedure 확인 및 수정 (0) | 2013.12.19 |
MySql DB 덤프 (0) | 2013.12.19 |