Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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³£ÓòÙ×÷»ù±¾²Ù×÷
MySQL³£ÓòÙ×÷»ù±¾²Ù×÷£¬ÒÔ϶¼ÊÇMySQL5.0ϲâÊÔͨ¹ýÊ×ÏÈ˵Ã÷Ï£¬¼ÇסÔÚÿ¸öÃüÁî½áÊøʱ¼ÓÉÏ£»£¨·ÖºÅ£©
1.µ¼³öÕû¸öÊý¾Ý¿â
mysqldump -u Óû§Ãû -p --default-character-set=latin1 Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû(Êý¾Ý¿âĬÈϱàÂëÊÇlatin1)
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc. ......

ÔÚmysqlÊý¾Ý¿âÖÐÈÕÆÚÓëlongÐ͵Äת»¯

1¡¢ÔÚmysql Êý¾Ý¿âÖУ¬“2009-09-15 00£º00£º00”ת»¯ÎªÁÐΪ³¤ÕûÐ͵ĺ¯Êý£º
select unix_timstamp("2009-09-15 00£º00£º00")*1000,
ÕâÀïҪעÒ⣬mysqlÊý¾Ý¿âÖеij¤ÕûÐÍ£¬±ÈjavaÖеij¤ÕûÐÍÉÙÁËÃëºóÃæµÄºÁÃëÊý£¬ËùÒÔÒª³ËÒÔ1000£¬ÕâÑùÖ»Óм¸ºÁÃëÖ®²î
2¡¢ÔÚmysqlÊý¾Ý¿âÖУ¬“1252999488000”£ ......

²é¿´¼°ÐÞ¸ÄmysqlÊý¾Ý¿âµÄĬÈϱàÂë2

ʹÓÃmysql ¾­³£»áÓöµ½±àÂëÎÊÌ⣬¶øµ¼Ö³ÌÐò³öÏÖÂÒÂë,mysql ÔÚÒÔϼ¸¸öµØ·½»áÉæ¼°µ½±àÂë¸ñʽ
Êý¾Ý¿â±àÂë
·þÎñÆ÷±àÂë
Á¬½Ó±àÂë
¿Í»§¶Ë±àÂë
ÏÂÃæÊÇÒ»¸öµäÐ͵ÄʾÀý£¬ ÔËÐÐ mysql -u root
²é¿´±àÂë mysql>status
mysql Ver 14.7 Distrib 4.1.14, for Win32 (ia32)
Connection id: 90
Current database: yitian ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ