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

MysqlµÄÓα꾿¾¹ÔõôÓÖӳÈպɻ¨±ðÑùºì


MysqlµÄÓα꾿¾¹ÔõôÓÖӳÈպɻ¨±ðÑùºì
Mysql´Ó5.0¿ªÊ¼Ö§³Ö´æ´¢¹ý³ÌºÍtrigger£¬¸øÎÒÃÇϲ»¶ÓÃmysqlµÄÅóÓÑÃǸüϲ»¶mysqlµÄÀíÓÉÁË£¬Óï·¨
ÉϺÍPL/SQLÓвî±ð£¬²»¹ý¸ã¹ý±à³ÌµÄÈ˶¼ÖªµÀ£¬Óï·¨²»ÊÇÎÊÌ⣬¹Ø¼üÊÇ˼Ï룬´óÖÂÁ˽âÓï·¨ºó£¬¾Í´Ó
±äÁ¿¶¨Ò壬ѭ»·£¬Åжϣ¬Óα꣬Òì³£´¦ÀíÕâ¸ö¼¸¸ö·½ÃæÏêϸѧϰÁË¡£¹ØÓÚÓαêµÄÓ÷¨MysqlÏÖÔÚÌṩ
µÄ»¹ºÜÌرð£¬ËäȻʹÓÃÆðÀ´Ã»ÓÐPL/SQLÄÇô˳ÊÖ£¬²»¹ýʹÓÃÉÏ´óÖÂÉÏ»¹ÊÇÒ»Ñù£¬
¶¨ÒåÓαê
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;
ʹÓÃÓαê
open fetchSeqCursor£»
fetchÊý¾Ý
fetch cursor into _seqname, _value;
¹Ø±ÕÓαê
close fetchSeqCursor;
²»¹ýÕⶼÊÇÕë¶ÔcursorµÄ²Ù×÷¶øÒÑ£¬ºÍPL/SQLûÓÐʲôÇø±ð°É£¬²»¹ý¹âÊÇÁ˽⵽Õâ¸öÊǸù±¾²»×ãÒÔ
д³öMysqlµÄfetch¹ý³ÌµÄ£¬»¹ÒªÁ˽âÆäËûµÄ¸üÉîÈëµÄ֪ʶ£¬ÎÒÃDzÅÄÜÕæÕýµÄд³öºÃµÄÓαêʹÓõÄproc
edure
Ê×ÏÈfetchÀë²»¿ªÑ­»·Óï¾ä£¬ÄÇôÏÈÁ˽âÒ»ÏÂÑ­»·°É¡£
ÎÒÒ»°ãʹÓÃLoopºÍwhile¾õµÃ±È½ÏÇå³þ£¬¶øÇÒ´úÂë¼òµ¥¡£
ÕâÀïʹÓÃLoopΪÀý
fetchSeqLoop:Loop
fetch cursor into _seqname, _value;
end Loop;
ÏÖÔÚÊÇËÀÑ­»·£¬»¹Ã»ÓÐÍ˳öµÄÌõ¼þ£¬ÄÇôÔÚÕâÀïºÍoracleÓÐÇø±ð£¬OracleµÄPL/SQLµÄÖ¸ÕëÓиöÒþÐÔ±ä
Á¿%notfound£¬MysqlÊÇͨ¹ýÒ»¸öError handlerµÄÉùÃ÷À´½øÐÐÅжϵģ¬
declare continue handler for Not found (do some action);
ÔÚMysqlÀïµ±Óαê±éÀúÒç³öʱ£¬»á³öÏÖÒ»¸öÔ¤¶¨ÒåµÄNOT FOUNDµÄError£¬ÎÒÃÇ´¦ÀíÕâ¸öError²¢¶¨ÒåÒ»
¸öcontinueµÄhandler¾Í¿ÉÒÔß·£¬¹ØÓÚMysql Error handler¿ÉÒÔ²éѯMysqlÊÖ²á
¶¨ÒåÒ»¸öflag£¬ÔÚNOT FOUND£¬±êʾFlag,ÔÚLoopÀïÒÔÕâ¸öflagΪ½áÊøÑ­»·µÄÅжϾͿÉÒÔß·¡£
declare fetchSeqOk boolean; ## define the flag for loop judgement
declare _seqname varchar(50); ## define the varient for store the data
declare _value bigint(20);
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;## define the cursor
declare continue handler for NOT FOUND set fetchSeqOk = true; ## define the continue handler for not
found flag
set fetchSeqOk = false;
open fetchSeqCursor;
fetchSeqLoop:Loop
if fetchSeqOk then
leave fetchSeqLoop;
else
fetch cursor into _seqname, _value;
select _seqname, _value;
end if;
end Loop;
close fetchSeqCur


Ïà¹ØÎĵµ£º

MySql °´Ê±¼ä¶Î²éѯÊý¾Ý·½·¨


¸ñʽΪ2008-06-16
²éѯ³öµ±ÌìÊý¾Ý£º
SELECT * from `table` WHERE date(ʱ¼ä×Ö¶Î) = curdate();
²éѯ³öµ±ÔÂ×ֶΣº
SELECT *
from `table`
WHERE month( ʱ¼ä×Ö¶Î) = month( now( ) ) ;
ʱ¼ä¸ñʽΪ1219876…… UNIXʱ¼ä£¬Ö»ÒªÓ¦ÓÓfrom_UNIXTIME( )”º¯Êý
ÀýÈç²éѯµ±Ô£º
SELECT ......

MySQL ±¸·ÝºÍ»Ö¸´

±¾ÎÄÌÖÂÛ MySQL µÄ±¸·ÝºÍ»Ö¸´»úÖÆ£¬ÒÔ¼°ÈçºÎά»¤Êý¾Ý±í£¬°üÀ¨×îÖ÷ÒªµÄÁ½ÖÖ±íÀàÐÍ£ºMyISAM ºÍ Innodb£¬ÎÄÖÐÉè¼ÆµÄ MySQL °æ±¾Îª 5.0.22¡£
Ä¿Ç° MySQL Ö§³ÖµÄÃâ·Ñ±¸·Ý¹¤¾ßÓУºmysqldump¡¢mysqlhotcopy£¬»¹¿ÉÒÔÓà SQL Óï·¨½øÐб¸·Ý£ºBACKUP TABLE »òÕß SELECT INTO OUTFILE£¬ÓÖ»òÕß±¸·Ý¶þ½øÖÆÈÕÖ¾£¨binlog£©£¬»¹¿ÉÒÔÊÇÖ±½Ó¿½± ......

²é¿´ MySql ×Ö·û¼¯

¹Ø¼ü×Ö: mysql


MySQL ÂÒÂëµÄ¸ùÔ´ÊÇµÄ MySQL ×Ö·û¼¯ÉèÖò»µ±µÄÎÊÌ⣬±¾ÎÄ»ã×ÜÁËÓйز鿴 MySQL ×Ö·û¼¯µÄÃüÁî¡£°üÀ¨²é¿´ MySQL Êý¾Ý¿â·þÎñÆ÷×Ö·û¼¯¡¢²é¿´ MySQL Êý¾Ý¿â×Ö·û¼¯£¬ÒÔ¼°Êý¾Ý±íºÍ×ֶεÄ×Ö·û¼¯¡¢µ±Ç°°²×°µÄ MySQL ËùÖ§³ÖµÄ×Ö·û¼¯µÈ¡£
Ò»¡¢²é¿´ MySQL Êý¾Ý¿â·þÎñÆ÷ºÍÊý¾Ý¿â×Ö·û¼¯¡£
mysql> show variab ......

Mysql ½»²æ²éѯ

CREATE TABLE `taa` (
   `year` varchar(4) DEFAULT NULL,
   `month` varchar(2) DEFAULT NULL,
   `amount` double DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf
"year","m ......

MySQL´æ´¢¹ý³ÌʵÀý

9.3  MySQL´æ´¢¹ý³Ì
MySQL 5.0ÒÔºóµÄ°æ±¾¿ªÊ¼Ö§³Ö´æ´¢¹ý³Ì£¬´æ´¢¹ý³Ì¾ßÓÐÒ»ÖÂÐÔ¡¢¸ßЧÐÔ¡¢°²È«ÐÔºÍÌåϵ½á¹¹µÈÌص㣬±¾½Ú½«Í¨¹ý¾ßÌåµÄʵÀý½²½âPHPÊÇÈçºÎ²Ù×ÝMySQL´æ´¢¹ý³ÌµÄ¡£
ʵÀý261£º´æ´¢¹ý³ÌµÄ´´½¨
ÕâÊÇÒ»¸ö´´½¨´æ´¢¹ý³ÌµÄʵÀý
¼ÏñλÖ㺹âÅÌ\mingrisoft\09\261
ʵÀý˵Ã÷
ΪÁ˱£Ö¤Êý¾ÝµÄÍêÕûÐÔ¡¢Ò»ÖÂÐÔ£¬Ìá ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ