mysql´æ´¢¹ý³Ì Àý×Ó Óαêcursor Ñ»·Ç¶Ì× ÊÂÎï
×òÌìÒªmysqlÖÐд´æ´¢¹ý³Ì·¢ÏÖÍøÉÏÓйØÓÚcursorÑ»·ÇÒÌ×µÄ×ÊÁϺÜÉÙ,ÏÖ·¢³ö±¾ÈËдµÄÀý×Ó,Ï£ÍûÄܶԴó¼ÒÓаïÖú.
¿´ÕÐ:
DELIMITER $$
USE `ad_db`$$
DROP PROCEDURE IF EXISTS `test`$$
CREATE DEFINER=`root`@`%` PROCEDURE `test`()
BEGIN
/** CPAЧ¹ûÊý */
DECLARE _tmpId1 INT;
DECLARE _tmpId2 VARCHAR(5000);
DECLARE not_found INT DEFAULT 0 ;-- ÊÇ·ñδÕÒµ½Êý¾Ý ±ê¼Ç
DECLARE cursor1 CURSOR FOR SELECT id from fhtest2 ; -- ²âÊÔÓÃÎÞÒµÎñ¹ØÏµ
DECLARE cursor2 CURSOR FOR SELECT test from fhtest2 ;-- ²âÊÔÓÃÎÞÒµÎñ¹ØÏµ
DECLARE CONTINUE HANDLER FOR NOT FOUND SET not_found = 1; -- Èç¹ûδÕÒµ½Êý¾Ý ½«±ê¼Ç¸ÄΪ²»¿ÉÓÃ
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK; -- Òì³£Ìø³ö
START TRANSACTION; -- Æô¶¯ÊÂÎï
INSERT INTO fhtest2 (test) VALUES (' ¿ªÊ¼1 ');
INSERT INTO fhtest2 (test) VALUES (' ¿ªÊ¼2 ');
OPEN cursor1; -- Æô¶¯Óαê1
WHILE not_found = 0 DO
FETCH cursor1 INTO _tmpId1;-- »ñÈ¡Êý¾Ý
IF NOT not_found THEN
OPEN cursor2; -- Æô¶¯Óαê2
WHILE not_found = 0 DO
FETCH cursor2 INTO _tmpId2;-- »ñÈ¡Êý¾Ý
IF NOT not_found THEN
INSERT INTO fhtest2 (test) VALUES (CONCAT(' id + test= ',_tmpId1,_tmpId2));
END IF ;
END WHILE ;
CLOSE cursor2;
SET not_found = 0 ; -- ½« ±ê¼Ç¸ÄΪ0¼´¿ÉÓà ·ñÔòÖ»Ö´ÐÐÒ»´Î,ÒÔΪÄÚ²¿Ñ»·Ö´ÐÐÍê³Éºó not_found = 1,ËùÓÐÒª½«ÆäÖÃΪ0
END IF;
END WHILE;
CLOSE cursor1;
COMMIT;
END$$
DELIMITER ;
Ïà¹ØÎĵµ£º
Link from : http://www.5ilinux.com/blog/archives/000091.html
1.Ê×ÏÈÎÒÃǽ¨Á¢ÏàÓ¦µÄÓû§ºÍÓû§×é
groupadd -g 5500 ftpgroup
adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser
2.²Ù×÷Êý¾Ý¿â
mysql mysql -uroot -ppassword
create database ftpdb
grant select, upd ......
¹«Ë¾µÄ·þÎñÆ÷ÊÇCentOS 5.4(Final)°æµÄ£¬½ñÌìÔÚÉÏÃæ°²×°ÁËÒ»»Ømysql5.5£¬¼Ç¼ÈçÏ£º
1¡¢´Óhttp://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.2-m2.tar.gz ÏÂÔØÔ´Âë°²×°°üµ½/usr/local/src
2¡¢tar zxvf mysql-5.5.2-m2.tar.gz ½âѹµ½/usr/local/src/mysql-5.5.2-m2ÏÂ
cd mysql-5.5.2-m2/
&n ......
ÒÔϵÄÎÄÕÂÊÇMySQL grantÓï·¨µÄÏêϸ½âÎö£¬Èç¹ûÄã¶ÔMySQL grantÓï·¨µÄÏà¹ØµÄʵ¼Ê²Ù×÷ÓÐÐËȤµÄ»°£¬Äã¾Í¿ÉÒÔ¶ÔÒÔϵÄÎÄÕµã»÷¹Û¿´ÁË¡£ÎÒÃÇ´ó¼Ò¶¼ÖªµÀMySQLÊý¾Ý¿â¸³ÓèÓû§È¨ÏÞÃüÁîµÄ¼òµ¥¸ñʽ¿É¸ÅÀ¨Îª£º
grant ȨÏÞ on Êý¾Ý¿â¶ÔÏó to Óû§
Ò»¡¢grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû¡£
grant ......
¾¡¿ÉÄܵØÊ¹ÓÃ×îÓÐЧ(×îС)µÄÀàÐÍ¡£MySQLÓкܶà½ÚÊ¡´ÅÅ̿ռäºÍÄÚ´æµÄרҵ»¯ÀàÐÍ¡£
Èç¹û¿ÉÄÜʹ±í¸üС£¬Ê¹ÓýÏСµÄÕûÊýÀàÐÍ¡£ÀýÈ磬MEDIUMINT¾³£±ÈINTºÃһЩ¡£
Èç¹û¿ÉÄÜ£¬ÉùÃ÷ÁÐΪNOT NULL¡£ËüʹÈκÎÊÂÇé¸ü¿ì¶øÇÒÄãΪÿÁнÚʡһλ¡£×¢ÒâÈç¹ûÔÚÄãµÄÓ¦ÓóÌÐòÖÐÄãȷʵÐèÒªNULL£¬ÄãÓ¦¸ÃºÁÎÞÒÉÎÊʹÓÃËü£¬Ö»ÊDZÜÃâȱʡµØÔÚËùÓ ......
1¡¢ÏÂÔØMySQLµÄLinux°²×°Îļþ
¡¡¡¡Linuxϰ²×°MySQLÐèÒªÏÂÃæÁ½¸öÎļþ£º
¡¡¡¡MySQL-server-5.1.7-0.i386.rpm
¡¡¡¡ÏÂÔØµØÖ·Îª£ºhttp://dev.mysql.com/downloads/mysql/5.1.html£¬´ò¿ª´ËÍøÒ³£¬ÏÂÀÍøÒ³ÕÒµ½“Linux x86 generic RPM (statically linked against glibc 2.2.5) downloads”ÏÕÒµ½“Ser ......