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

MYSQL °üº¬ÊÂÎï,²ÎÊý,ÓαêµÈµÄ×ÛºÏʹÓÃÀý×Ó,Ç°ÕÂ(1)

----------------------------------------------------------------------
--¸Ã´æ´¢¹ý³ÌÓû§´¦ÀíÐÅÏ¢,µ±Êý¾Ý²»´æÔÚ±íÖÐʱÔò²åÈç,·ñÔò¾Íɾ³ý
--Ö»ÓÃÁ˼òµ¥µÄÊÂÎñ,ÏÂÃ潫Óиü¸´ÔÓµÄÀý×Ó
--pro_produce ²úÆ·±í(pname.p_id(±àºÅ,Ö÷¼ü),ptime(Ìí¼Óʱ¼ä))
--
--
--
-------------------------------------------------------------------------
create procedure pro_produce(
in pname varchar(50),
in pb int,
in ptime datetime,
out rtn int)
begin
declare al_d int default -1;
     [--Èç¹û³öÏÖÒì,»ò×Ô¶¯´¦Àí²¢ÇÒrollback,µ«²»ÔÙ֪ͨµ÷Ó÷½(×¢Òâ:µ«Èç¹ûÏ£Íûµ÷Ó÷½µÃµ½ÏûÏ¢,ÐèÒªÕâÒ»¾ä:declare exit handler for sqlexception rollback;ÒÔ¼°Æô¶¯ÊÂÎñºÍÌá½»ÊÂÎñµÄÓï¾äÈ«²¿È¥µô)]
select p_id into al_d from t_produce where p_name=pname;
 if al_d=-1 then
--¿ªÆôÊÂÎñ
start transcation;
nsert into t_produce value(pname,pb,ptime);
 --Ìí¼ÓÈÕ¼Ç
  insert into t_log  where (datetime,'Ìí¼ÓÁËвúÆ·');
--Ìá½»ÊÂÎñ
set rtn=1;
commit;
else
set rtn=0;
end if;
end


Ïà¹ØÎĵµ£º

MySQL 5.4µÄÐÂÌØÐÔ½âÎö

Author: Ivan@mysqlab.net/Ì·¿¡Çà תÔØÇë×¢Ã÷À´Ô´URIÁ´½Ó:
http://www.mysqlab.net/blog/2009/04/mysql-54µÄÐÂÌØÐÔ½âÎö/
MySQL 5.4 Ö®ËùÒÔÃüÃûΪ5.4£¬¶ø²»ÊÇ5.2 ÊÇÒòΪ֮ǰµÄ5.2°æ±¾±»ÃüÃûΪ6.0ÁË£¨Õâ¸öÓ¦¸ÃÊÇÉÌÒµÉϵÄÔ­Òò£¬¾ÍÏñjava1.6±»ÃüÃûΪ6.0£©¡£ÏÖÔÚµÄ5.4 preview release ÊÇÔÚµ±Ç°MySQL5.1µÄ»ù´¡ÉÏ£¬¶Ô Innodb ½ø ......

mysqlά»¤³£ÓÃÃüÁî

Analyze Table
MySQL µÄOptimizer£¨ÓÅ»¯Ôª¼þ£©ÔÚÓÅ»¯SQLÓï¾äʱ£¬Ê×ÏÈÐèÒªÊÕ¼¯Ò»Ð©Ïà¹ØÐÅÏ¢£¬ÆäÖоͰüÀ¨±íµÄcardinality£¨¿ÉÒÔ·­ÒëΪ“É¢Áг̶Ȕ£©£¬Ëü±íʾij¸öË÷Òý¶ÔÓ¦µÄÁаüº¬¶àÉÙ¸ö²»Í¬µÄÖµ——Èç¹ûcardinality´ó´óÉÙÓÚÊý¾ÝµÄʵ¼ÊÉ¢Áг̶ȣ¬ÄÇôË÷Òý¾Í»ù±¾Ê§Ð§ÁË¡£
ÎÒÃÇ¿ÉÒÔʹÓÃSHOW& ......

mysql´¦Àíº£Á¿Êý¾ÝµÄÓÅ»¯ÅäÖÃ

³£³£Óöµ½´óÊý¾ÝÁ¿Æµ·±¶ÁдÊƱػᵼÖ·þÎñÆ÷µÄÐÔÄÜϽµ¡£ÏÂÃæ¼Ç¼һ϶ÔmysqlµÄÓÅ»¯ÅäÖÃ
1.Ê×ÏȹرÕauto commit¡£
2.¶ÔÓÚÊý¾Ý±íʹÓÃInnoDB¡£
3.¹Ø±ÕÍâ¼üÔ¼Êø¡£
4.²ÉÓöàÖµ²åÈë“INSERT INTO ±íÃû VALUES (1,2), (5,5), ...;” Èç¹ûÓдóÁ¿²¢·¢¿ÉÒÔÓøü¸ÄINSERT INTOΪ INSERT DELAYED INTO¿ÉÒÔÔڳ̶ÈÉϽ⾠......

MySQLµÄ±íËøÎÊÌâ(Ò»)

  ÔÚmysqlÊÖ²áÀïÃæÓÐÒ»¶ÎÃèÊö¹ØÓÚlock tablesµÄÓï·¨µÄ. LOCK TABLES
    tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE}
    [, tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE}] ...
UNLOCK TABLES
READ
µ±±í²»´æÔÚ WRITE дËøʱ READ ¶ÁËø±»Ö´ÐÐ,Õâ¸Ã ......

MYSQL °üº¬ÊÂÎï,²ÎÊý,ÓαêµÈµÄ×ÛºÏʹÓÃÀý×Ó,Ç°ÕÂ(1)

  1.Ê×ÏȵöÔmysql ÀïÃæµÄ²ÎÊý½øÐнéÉÜÏÂ:
     procedure--in:ÊäÈë²ÎÊý,outÊä³ö²ÎÊý,inoutÕâ¸ö¾Í²»ÓÃ˵ÁË,´ó¸ÅÒ²²Âµ½ÁË
                       declare:ÉùÃ÷±äÁ¿.¼ÇÖ÷, ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ