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

mysql´æ´¢¹ý³Ì¼ò½é

Õª×Ôhttp://blog.csdn.net/ljah/archive/2006/11/08/1373959.aspx
¸ñʽ£º
CREATE PROCEDURE ¹ý³ÌÃû ([¹ý³Ì²ÎÊý[,...]])
[ÌØÐÔ ...] ¹ý³ÌÌå
CREATE FUNCTION º¯ÊýÃû ([º¯Êý²ÎÊý[,...]])
RETURNS ·µ»ØÀàÐÍ
[ÌØÐÔ ...] º¯ÊýÌå
¹ý³Ì²ÎÊý:
[ IN | OUT | INOUT ] ²ÎÊýÃû ²ÎÊýÀàÐÍ
º¯Êý²ÎÊý:
²ÎÊýÃû ²ÎÊýÀàÐÍ
·µ»ØÀàÐÍ:
ÓÐЧµÄMySQLÊý¾ÝÀàÐͼ´¿É
ÌØÐÔ:
LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'
¹ý³ÌÌå/º¯ÊýÌå:¸ñʽÈçÏ£º
BEGIN
ÓÐЧµÄSQLÓï¾ä
END
ÎÒÔÚÕâÀï²»¹ØÐÄרÓеÄÌØÐÔ£¬ÕâЩÓëSQL¹æ·¶²»¼æÈÝ£¬ËùÒÔcharacteristic(ÌØÐÔ)µÄÏà¹ØÄÚÈݲ»×÷¿¼ÂÇ¡£
//
ÔÚ¿ª·¢¹ý³ÌÖÐÓм¸µãҪעÒ⣺
1¡¢´æ´¢¹ý³Ì×¢ÊÍ:MySQLÖ§³Ö²ÉÓÃ--»òÕß/**/×¢ÊÍ£¬ÆäÖÐÇ°ÕßÊÇÐÐ×¢ÊÍ£¬ºóÕßÊǶÎʽעÊÍ
2¡¢±äÁ¿Ê×ÏÈÓÃdeclareÉêÃ÷£¬ÆäÖÐÁÙʱ±äÁ¿¿ÉÒÔÖ±½ÓÒÔ@ǰ׺ÐÞÊÎÒÔ¹©ÒýÓÃ
3¡¢Ö±½Ó²ÉÓÃMySQLµÄAdministrator¹ÜÀíÆ÷±à¼­Ê±£¬¿ÉÒÔÖ±½Ó²ÉÓÃÈçϺ¯ÊýÎı¾Â¼È룻
µ«ÈôÔڽű¾ÖÐ×Ô¶¯µ¼Èë´æ´¢¹ý³Ì»òº¯Êýʱ£¬ÓÉÓÚMySQLĬÈÏÒÔ";"Ϊ·Ö¸ô·û£¬Ôò¹ý³ÌÌåµÄÿһ¾ä¶¼±»MySQLÒÔ´æ´¢¹ý³Ì±àÒ룬Ôò±àÒë¹ý³Ì»á±¨´í
£»ËùÒÔÒªÊÂÏÈÓÃDELIMITER¹Ø¼ü×ÖÉêÃ÷µ±Ç°¶Î·Ö¸ô·ûÓÃÍêÁ˾Ͱѷָô·û»¹Ô­¡£ ÈçÏÂËùʾ£º
DELIMITER ¡ç¡ç
Stored Procedures and Functions
DELIMITER ;
4¡¢MySQLÖ§³Ö´óÁ¿µÄÄÚǶº¯Êý£¬ÓÐЩÊǺʹóÐÍÉÌÓÃÊý¾Ý¿âÈçoracle¡¢informix¡¢sybaseµÈÒ»Ö£¬µ«Ò²ÓÐЩº¯ÊýÃû³Æ²»Ò»Ö£¬µ«¹¦ÄÜÒ»Ö£»»òÕß
ÓÐЩÃû³ÆÒ»Ö£¬µ«¹¦ÄÜÏàÒ죬Õâ¸öÌرð¶ÔÓÚ´ÓÕâЩÊý¾Ý¿â¿ª·¢×ª¹ýÀ´µÄDBAҪעÒâ¡£
5¡¢´æ´¢¹ý³Ì»òº¯ÊýµÄµ÷ÊÔ£ºÎÒÄ¿Ç°»¹Ã»ÓÐÑо¿MySQLËù´øµÄ¸÷ÖÖ¹¤¾ß°ü£¬»¹²»Çå³þÆäÌṩÁ˵÷ÊÔ¹¤¾ßûÓУ¬²»¹ý±àÒë´íÎóÏà¶ÔºÃ²éÕÒ£»ÖÁÓÚÒµÎñÁ÷³ÌµÄµ÷ÊÔ£¬¿ÉÒÔ²ÉÓÃÒ»¸ö±È½Ï±¿µÄ·½·¨£¬¾ÍÊÇ´´½¨Ò»¸öµ÷ÊÔ±í£¬ÔÚ°üÌåÖи÷¸öÁ÷³Ìµã¶¼²åÈëÒ»Ìõ¼Ç¼£¬ÒÔ¹Û²ì³ÌÐòÖ´ÐÐÁ÷³Ì¡£ÕâÒ²ÊÇÒ»¸ö±È½Ï·½±ãµÄ±¿°ì·¨¡£^_^
 
 
ÏÂÎÄÕª×Ôhttp://www.ccvita.com/100.html
Ò».´´½¨´æ´¢¹ý³Ì
1.»ù±¾Óï·¨£º
create procedure sp_name()
begin
………
end
2.²ÎÊý´«µÝ
¶þ.µ÷Óô洢¹ý³Ì
1.»ù±¾Óï·¨£ºcall sp_name()
×¢Ò⣺´æ´¢¹ý³ÌÃû³ÆºóÃæ±ØÐë¼ÓÀ¨ºÅ£¬ÄÄŸô洢¹ý³ÌûÓвÎÊý´«µÝ
Èý.ɾ³ý´æ´¢¹ý³Ì
1.»ù±¾Óï·¨£º
drop procedure sp_name//
2.×¢ÒâÊÂÏî
(1)²»ÄÜÔÚÒ»¸ö´æ´¢¹ý³ÌÖ


Ïà¹ØÎĵµ£º

MySQL Êý¾ÝÀàÐÍ Ïê½â


ÊýÖµÀàÐÍ
¡¡¡¡MySQL µÄÊýÖµÊý¾ÝÀàÐÍ¿ÉÒÔ´óÖ»®·ÖΪÁ½¸öÀà±ð£¬Ò»¸öÊÇÕûÊý£¬ÁíÒ»¸öÊǸ¡µãÊý»òСÊý¡£Ðí¶à²»Í¬µÄ×ÓÀàÐͶÔÕâЩÀà±ðÖеÄÿһ¸ö¶¼ÊÇ¿ÉÓõģ¬Ã¿¸ö×ÓÀàÐÍÖ§³Ö²»Í¬´óСµÄÊý¾Ý£¬²¢ÇÒ MySQL ÔÊÐíÎÒÃÇÖ¸¶¨ÊýÖµ×Ö¶ÎÖеÄÖµÊÇ·ñÓÐÕý¸ºÖ®·Ö»òÕßÓÃÁãÌî²¹¡£
¡¡¡¡±íÁгöÁ˸÷ÖÖÊýÖµÀàÐÍÒÔ¼°ËüÃǵÄÔÊÐí·¶Î§ºÍÕ¼ÓõÄÄÚ´æ¿Õ¼ä¡£ ......

mysql explainÖеÄusing filesort

Using filesort±íʾÔÚË÷ÒýÖ®Í⣬ÐèÒª¶îÍâ½øÐÐÍⲿµÄÅÅÐò¶¯×÷¡£µ¼Ö¸ÃÎÊÌâµÄÔ­ÒòÒ»°ãºÍorder byÓÐÕßÖ±½Ó¹Øϵ£¬Ò»°ã¿ÉÒÔͨ¹ýºÏÊʵÄË÷ÒýÀ´¼õÉÙ»òÕß±ÜÃâ¡£
explain SELECT * from table_item WHERE user_id = 2 ORDER BY item_id LIMIT 0, 5
user_id ºÍ item_id ·Ö±ð½¨Á¢Ò»¸öË÷Òý£¬¶Ô´ËÓï¾äMySQLÑ¡ÔñÁË user_idË÷Òý£¬ÄÇô ite ......

MySQL µÄ±í¼¶Ëø

 ÔÚ¿ª·¢ÏîĿʱ£¬Óöµ½Ò»¸öÎÊÌ⣬¾ÍÊÇÒªËæ»ú¶ÁÈ¡Ò»ÕűíµÄ²¿·Ö¼Ç¼£¬²¢updateÉèÖÃΪ²»¿ÉÔÚ¶Á£¬ÕâÀï¾ÍÓÐÒ»¸öÎÊÌ⣬¿ÉÄܶà¸öÈËͬʱËæ»úµ½ÏàͬµÄ¼Ç¼£¬²¢Öظ´×öupdate²Ù×÷£¬ÒýÆðÊý¾ÝÔà¶ÁºÍÖظ´²Ù×÷£¬
Òò´Ë¿¼ÂǸø±í¼ÓËø¡£µ«ÊDzÉÓÃÁËMyISAM£¬²»Ö§³ÖÊÂÎñ£¬Ö»ÄÜ¼Ó±í¼¶Ëø£¬¶øÇÒ±ðÈËÁ¬¶ÁµÄȨÏÞ¶¼Ã»ÓС£ÏÂÃæÊÇ2¸ö²âÊÔÎļþ£¬ÔÚfiref ......

mysql frontʹÓÃ×¢ÒâÊÂÏî

1.mysqlÊÇÒ»¸ö·Ç³£·½±ãµÄ¹ÜÀímysql·þÎñÆ÷µÄ¿Í»§¶ËÈí¼þ¡£ ´´½¨Ò»¸ömysql·þÎñÆ÷µÄÁ¬½ÓµÄʱºòÓ¦¸Ã×¢ÒâÌîдÐÅÏ¢µÄʱºòÏÈÔÚ×¢²áÀ¸ÌîдµÇ½Óû§ÃûºÍÃÜÂ룬ÔÙÔÚÁ¬½ÓÀ¸Ìîд·þÎñÆ÷Ãû£¬¶Ë¿ÚºÅ¡£
2.ʹÓÃmysql-frontµÄʱºò£¬½¨Á¢Ò»¸öµÇ½ÊôÐÔÒÔºó£¬ÔÙÔÚÃüÁîÐвÙ×÷mysqlÊý¾Ý¿â£¬mysql-frontµÄÊý¾ÝÐèÒªÊÖ¶¯Í¬²½²Å¿ÉÒÔ¿´µ½Ê¹ÓÃÃüÁîÐжÔÊý¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ