Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Mysql´æ´¢¹ý³Ì£¨Î壩——SEQUENCEµÄʵÏÖ

ÔÚ
oracle
ÖУ¬
sequence
Ìṩ¶à±í¶à×ֶοɹ²ÓÃÒ»¸ö²»Öظ´Öµ¡£
Mysql
ÖдæÔÚ×ÔÔöÁУ¬»ù±¾¿ÉÒÔÂú×ã
PK
µÄÒªÇó¡£µ«×ÔÔöÁдæÔÚÏÞÖÆ£º
a.
Ö»ÄÜÓÃÓÚ±íÖеÄÒ»¸ö×ֶΣ¬Ò»ÕŲ»ÄÜͬʱ´æÔÚÁ½¸öÒÔÉϵÄ×ÔÔöÁÐ
;
b.
×ÔÔöÁбØÐë±»¶¨ÒåΪ
key
£¨
PK
»ò
FK
£©
;
c.
×ÔÔöÁв»Äܱ»¶à¸ö±í¹²ÓÃ
;
d.
µ±
insert
Óï¾ä²»°üÀ¨×ÔÔö×ֶλò½«ÆäÖµÉèÖÃΪ
NULL
ʱ£¬¸ÃÖµ»á×Ô¶¯ÌîÉÏ¡£
                  
ÔÚ²»ÒªÇó×Ö¶Î˳ÐòµÝÔöµÄÇé¿öÏ£¬¿ÉÒÔÔÚ
Mysql
ÖÐʵÏÖÐòÁУº
        
Sql
code 5-1:
                  
DROP TABLE IF EXISTS sequence;

-- ½¨sequence±í£¬Ö¸¶¨seqÁÐΪÎÞ·ûºÅ´óÕûÐÍ£¬¿ÉÖ§³ÖÎÞ·ûºÅÖµ£º0(default)µ½18446744073709551615£¨0µ½2^64–1£©¡£
CREATE TABLE sequence (
name VARCHAR(50) NOT NULL,
current_value BIGINT UNSIGNED NOT NULL DEFAULT 0,
increment INT NOT NULL DEFAULT 1,
PRIMARY KEY (name) -- ²»ÔÊÐíÖظ´seqµÄ´æÔÚ¡£
) ENGINE=InnoDB;


DELIMITER /

DROP FUNCTION IF EXISTS currval /

CREATE FUNCTION currval(seq_name VARCHAR(50))
RETURNS BIGINT
BEGIN
DECLARE value BIGINT;
SELECT current_value INTO value
from sequence
WHERE upper(name) = upper(seq_name); -- ´óСд²»Çø·Ö.
RETURN value;
END;
/

DELIMITER ;


DELIMITER /

DROP FUNCTION IF EXISTS nextval /

CREATE FUNCTION nextval (seq_name VARCHAR(50))
RETURNS BIGINT
BEGIN
DECLARE value BIGINT;
UPDATE sequence
SET current_value = current_value + increment
WHERE upper(name) = upper(seq_name);
RETURN currval(seq_name);
END;
/

DELIMITER ;

DELIMITER /

DROP FUNCTION IF EXISTS setval /

CREATE FUNCTION setval (seq_name VARCHAR(50), value BIGINT)
RETURNS BIGINT
BEGIN
UPDATE seque


Ïà¹ØÎĵµ£º

MySQL ÄÚ´æÄ£ÐÍ hust ei

¶ÔÓÚÈκÎÒ»¸öÊý¾Ý¿â¹ÜÀíϵͳÀ´Ëµ£¬ÄÚ´æµÄ·ÖÅäʹÓþø¶Ô¿ÉÒÔËãµÄÉÏÊÇÆäºËÐÄÖ®Ò»ÁË£¬ËùÒԺܶàÏ£Íû¸üΪÉîÈëÁ˽âijÊý¾Ý¿â¹ÜÀíϵͳµÄÈË£¬¶¼»áÏ£ÍûÒ»¿ú¾¿¾¹£¬ÎÒÒ²²»ÀýÍâ¡£
´ÓÄÚ´æµÄʹÓ÷½Ê½MySQL Êý¾Ý¿âµÄÄÚ´æʹÓÃÖ÷Òª·ÖΪÒÔÏÂÁ½Àà
* Ï̶߳ÀÏíÄÚ´æ
* È«¾Ö¹²ÏíÄÚ´æ
½ñÌìÕâƪÎÄÕÂÔÝʱÏÈ·ÖÎö MySQL ÖÐÖ÷ÒªµÄ “Ï̶߳ÀÏíÄ ......

Ubuntu Server9 Mysql °²×°ÈçÏÂ

Òª°²×° MySQL£¬¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÏÂÁÐÃüÁ
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql
// °²×°php5-mysql Êǽ«phpºÍmysqlÁ¬½ÓÆðÀ´
Ò»µ©°²×°Íê³É£¬MySQL ·þÎñÆ÷Ó¦¸Ã×Ô¶¯Æô¶¯¡£Äú¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÒÔÏÂÃüÁîÀ´¼ì²é MySQL ·þÎñÆ÷ÊÇ·ñÕýÔÚÔËÐУº ......

MySQLÓÅ»¯

MySQLÓÅ»¯
ͬʱÔÚÏß·ÃÎÊÁ¿¼ÌÐøÔö´ó£¬¶ÔÓÚ1GÄÚ´æµÄ·þÎñÆ÷Ã÷ÏԸоõµ½³ÔÁ¦ÑÏÖØʱÉõÖÁÿÌ춼»áËÀ»ú£¬»òÕßʱ²»Ê±µÄ·þÎñÆ÷¿¨Ò»Ï£¬Õâ¸öÎÊÌâÔø¾­À§ÈÅÁËÎÒ°ë¸ö¶àÔ¡£MySQLʹÓÃÊǺܾßÉìËõÐÔµÄËã·¨£¬Òò´ËÄãͨ³£ÄÜÓúÜÉÙµÄÄÚ´æÔËÐлò¸øMySQL¸ü¶àµÄ±»´æÒԵõ½¸üºÃµÄÐÔÄÜ¡£
°²×°ºÃmysqlºó£¬ÅäÖÆÎļþÓ¦¸ÃÔÚ/usr/local/mysql/share/mysql ......

¼òµ¥²âÊÔMySQL 5.1 ±í·ÖÇø¹¦ÄÜ

Ïë²âÊÔϱí·ÖÇø¹¦Äܸú×ÔÖ÷µÄ·Ö²¼Ê½µÄÐÔÄܲîÒ죬½øÐÐÁ˼òµ¥µÄ²âÊÔ£¬Ç°ºó»¨·ÑÁË°ë¸öСʱ£¬¿ÉÄܲâÊÔÊý¾Ý²»Ì«×¼È·¡£
¡¾²âÊÔ»·¾³¡¿
²Ù×÷ϵͳ£ºWindows XP SP2
MySQL£º 5.1.19-beta-community-nt-debug
¡¾²âÊÔ¹ý³Ì¡¿
²é¿´MySQL°æ±¾£º
mysql> select version();
+--------------------------------+
| version() ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ