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

mysql´æ´¢¹ý³Ì£¬Óα꣬ÊÂÎï

drop procedure if exists pro_rep_shadow_rs;
delimiter |
----------------------------------
-- rep_shadow_rs
-- ÓÃÀ´´¦ÀíÐÅÏ¢µÄÔö¼Ó£¬¸üкÍɾ³ý
-- ÿ´ÎÖ»¸üÐÂÉÏ´ÎÒÔÀ´Ã»ÓÐ×ö¹ýµÄÊý¾Ý
-- ¸ù¾Ý²»Í¬µÄ±ê־λ
-- ÐèÒªÒ»¸öÊä³öµÄ²ÎÊý£¬
-- Èç¹û·µ»ØΪ0£¬Ôòµ÷ÓÃʧ°Ü£¬ÊÂÎñ»Ø¹ö
-- Èç¹û·µ»ØΪ1£¬µ÷Óóɹ¦£¬ÊÂÎñÌá½»
--
-- ²âÊÔ·½·¨
-- call pro_rep_shadow_rs(@rtn);
-- select @rtn;
----------------------------------
create procedure pro_rep_shadow_rs(out rtn int)
begin
-- ÉùÃ÷±äÁ¿£¬ËùÓеÄÉùÃ÷±ØÐëÔÚ·ÇÉùÃ÷µÄÓï¾äÇ°Ãæ
declare iLast_rep_sync_id int default -1;
declare iMax_rep_sync_id int default -1;
-- Èç¹û³öÏÖÒì³££¬»ò×Ô¶¯´¦Àí²¢rollback,µ«²»ÔÙ֪ͨµ÷Ó÷½ÁË
-- Èç¹ûÏ£ÍûÓ¦ÓûñµÃÒì³££¬ÐèÒª½«ÏÂÃæÕâÒ»¾ä£¬ÒÔ¼°Æô¶¯ÊÂÎñºÍÌá½»ÊÂÎñµÄÓï¾äÈ«²¿È¥µô
declare exit handler for sqlexception rollback;
-- ²éÕÒÉÏÒ»´ÎµÄ
select eid into iLast_rep_sync_id from rep_de_proc_log where tbl='rep_shadow_rs';
-- Èç¹û²»´æÔÚ£¬ÔòÔö¼ÓÒ»ÐÐ
if iLast_rep_sync_id=-1 then
insert into rep_de_proc_log(rid,eid,tbl) values(0,0,'rep_shadow_rs');
set iLast_rep_sync_id = 0;
end if;

-- ÏÂÒ»¸öÊý×Ö
set iLast_rep_sync_id=iLast_rep_sync_id+1;
-- ÉèÖÃĬÈϵķµ»ØֵΪ0£ºÊ§°Ü
set rtn=0;

-- Æô¶¯ÊÂÎñ
start transaction;
-- ²éÕÒ×î´ó±àºÅ
select max(rep_sync_id) into iMax_rep_sync_id from rep_shadow_rs;
-- ÓÐÐÂÊý¾Ý
if iMax_rep_sync_id>=iLast_rep_sync_id then
-- µ÷ÓÃ
call pro_rep_shadow_rs_do(iLast_rep_sync_id,iMax_rep_sync_id);
-- ¸üÐÂÈÕÖ¾
update rep_de_proc_log set rid=iLast_rep_sync_id,eid=iMax_rep_sync_id where tbl='rep_shadow_rs';
end if;

-- ÔËÐÐûÓÐÒì³££¬Ìá½»ÊÂÎñ
commit;
-- ÉèÖ÷µ»ØֵΪ1
set rtn=1;
end;
|
delimiter ;
drop procedure if exists pro_rep_shadow_rs_do;
delimiter


Ïà¹ØÎĵµ£º

MySQL±íÀàÐͼòµ¥¶Ô±È

MySQLΪÎÒÃÇÌṩÁ˺ܶà±íÀàÐ͹©Ñ¡Ôñ£¬ÓÐMyISAM¡¢ISAM¡¢HEAP¡¢BerkeleyDB¡¢InnoDB£¬MERGE±íÀàÐÍÿһÖÖ±íÀàÐͶ¼ÓÐÆä×Ô¼ºµÄÊôÐÔºÍÓŵ㡣ÏÂÃæÎÒÃÇÀ´¼òµ¥µÄÌÖÂÛһϡ£
MyISAM±íÀàÐÍ£º
MyISAM
±í(TYPE=MYISAM)ÊÇISAMÀàÐ͵ÄÒ»ÖÖÑÓÉ죬¾ßÓкܶàÓÅ»¯ºÍÔöÇ¿µÄÌØÐÔ¡£ÊÇMySQLµÄĬÈϱíÀàÐÍ¡£MyISAMÓÅ»¯ÁËѹËõ±ÈÀýºÍËٶȣ¬²¢ÇÒ
¿ÉÒ& ......

MySQLÖ÷´Ó·þÎñÆ÷£¨Replication£©µÄÉèÖÃ

Ê×ÏÈÉèÖÃMySQLÖ÷·þÎñÆ÷£º
ÔÚÖ÷·þÎñÆ÷ÉÏΪ´Ó·þÎñÆ÷½¨Á¢Ò»¸öÓû§£º
grant replication slave on *.* to 'Óû§Ãû'@'Ö÷»ú' identified by 'ÃÜÂë';
Èç¹ûʹÓõÄÊÇMySQL 4.0.2֮ǰµÄ°æ±¾£¬ÔòÓÃfileȨÏÞÀ´´úÌæreplication slave
±à¼­Ö÷·þÎñÆ÷µÄÅäÖÃÎļþ£º/etc/my.cnf
server-id=1
log-bin
binlog-do-db=ÐèÒª¸´ÖƵÄÊý¾Ý¿âÃû£ ......

mysql×Ó²éѯ exists,not exists


(1)ʵÏÖÈýá¹û¼¯A-½á¹û¼¯B£º--ÀûÓÃnot
exists£¬ºÏ²¢Ôò¿ÉÓÃunion
exists,not
exists£ºÓÃÓÚÅжÏÇÒ»ñÈ¡½á¹û¼¯AÊÇ·ñ´æÔڵؽá¹û¼¯BÖÐ!
==========½á¹û¼¯A£º
SELECT
d.Device_ID,d.Device_Name,a.App_ID,a.App_Name
               from
T_ ......

MySQLÖеÄmysqldumpÃüÁîʹÓÃÏê½â

MySQLÓкܶà¿ÉÒÔµ¼ÈëÊý¾ÝµÄ·½·¨£¬È»¶øÕâЩֻÊÇÊý¾Ý´«ÊäÖеÄÒ»°ë£¬ÁíÍâµÄÒ»°ãÊÇ´ÓMySQLÊý¾Ý¿âÖе¼³öÊý¾Ý¡£ÓÐÐí¶àµÄÔ­ÒòÎÒÃÇÐèÒªµ¼³öÊý¾Ý¡£Ò»¸öÖØÒªµÄÔ­ÒòÊÇÓÃÓÚ±¸·ÝÊý¾Ý¿â¡£Êý¾ÝµÄÔì¼Û³£³£ÊÇ°º¹óµÄ£¬ÐèÒª½÷É÷´¦ÀíËüÃÇ¡£¾­³£µØ±¸·Ý¿ÉÒÔ°ïÖú·ÀÖ¹±¦¹óÊý¾ÝµØ¶ªÊ§£»ÁíÍâÒ»¸öÔ­ÒòÊÇ£¬Ò²ÐíÄúÏ£Íûµ¼³öÊý¾ÝÀ´¹²Ïí¡£ ÔÚÕâ¸öÐÅÏ¢¼¼Êõ²»¶ ......

java mysql ºº×Ö´æÈëʱÂÒÂë


´ÓÍøÂçÕª³­µ½µÄ½â¾ö·½·¨——
½â¾ö·½·¨¶þ£º
      Á¬½Ómysqlʱ(ÎÞÂÛÔÚ´Ómysql¶Á»¹ÊÇÈ¡Êý¾ÝµÄÇé¿ö)£¬Ö¸¶¨Ê¹ÓõıàÂ뷽ʽΪutf-8£¬¾ßÌå´úÂëÈçÏÂ
      //×°ÔØmysql-jdbcÇý¶¯
       Class.forName("com.mysql.jdbc.Driver" ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ