hibernate Éú³ÉµÄ sql Óï¾ä £¿ ´úÖµ
ת×Ô£º http://hi.baidu.com/beanchx/blog/item/ed056509d66f65cc3bc763f4.html
p6spyµÄÌæ´úÆ·£ºjdbc logger
2007Äê09ÔÂ13ÈÕ ÏÂÎç 01:07
Ê×ÏȽéÉÜÒ»ÏÂÕâ¸ö¿ªÔ´µÄÏîÄ¿¡£Õâ¸öÊÇÒ»¸ö¶ÔjdbcÖеÄsql½øÐÐloggerµÄÒ»¸ö¹¤¾ß¡£ÈôÔÚÏîÄ¿ÖвÉÓÃÁ˽϶àµÄpreparedStatement£¬ÄÇô´òÓ¡³öÀ´µÄsql»áÓкܶà"?"£¬·Ç³£²»·½±ã¡£ÓÐÒ»¸ö²úƷΪp6spy£¬¿ÉÒÔÍê³ÉÏÔʾ³öÎʺŵÄÄÚÈÝ£¬µ«ÊÇÄ¿Ç°ÒѾֹͣ¸üÐÂÁË¡£jdbclogger¾ÍÊÇÒ»¸öp6spyµÄÌæ´úÆ·£¬¶øÇҷdz£ÇáÇÉ£¬½ö½ö22k´óС¡£Ä¿Ç°jdbc loggerÖ§³ÖµÄÊý¾Ý¿âΪ£ºmysql¡¢oracle¡¢hsqldb¡¢postgresql¡£
jdbc loggerµÄ¹Ù·½ÍøվΪ£ºhttp://jdbclogger.sourceforge.net/index.html
ÏÂÃæ¿´Ò»ÏÂÈçºÎÅäÖÃʹÓÃÕâ¸öjdbc logger¡£
²½Öè1£ºÏÂÔØjdbclogger£¬ÓÐÔ´ÂëÒÔ¼°jarÎļþÏÂÔØ¡£Ä¿Ç°jdbc loggerΪ0.5°æ±¾¡£
ÏÂÔصØÖ·ÈçÏ£º
http://sourceforge.net/projects/jdbclogger/files
ÓÐËĸöjarÎļþ¿ÉÒÔÏÂÔØ£¬ÈôʹÓÃoracleÊý¾Ý¿âµÄ»°£¬¿ÉÄÜÐèÒªÏÂÔØÏÂÃæµÄÁ½¸öjar°ü¡£
Ìáʾ£º¸ÃÏîÄ¿±ØÐëʹÓÃlog4j£¬ÈôûÓÐʹÓùý£¬Çë²é¿´Ïà¹ØÎÄÕ¡£
²½Öè2£ºÏÂÔØÒԺ󣬰ÑÕâ¸öjar°ü·Åµ½¹¤³ÌµÄclasspathÏÂÃæ¡£ÈôÊÇwebÏîÄ¿£¬Ôò·ÅÔÚweb-inf/libĿ¼ÏÂÃæ¡£
²½Öè3£ºÔÚlog4j.propertiesÎļþÖУ¬Ìí¼ÓÈçÏ´úÂ룺
log4j.logger.net.sourceforge.jdbclogger=DEBUG
²½Öè4£ºÁíÍ⣬ÔÚsrcÎļþ¼ÐÏÂÃ潨Á¢Ò»jdbclogger.propertiesÎļþ£¬ÄÚÈÝÈçÏ£º
jdbclogger.driver=org.hsqldb.jdbcDriver
Ìáʾ:²»Í¬µÄÊý¾Ý¿â²ÉÓò»Í¬µÄÊý¾Ý¿âÇý¶¯³ÌÐò£¬ÕâÀïjdbclogger.driverµÄÖµ¾ÍÊÇÄãµÄÊý¾Ý¿âÇý¶¯³ÌÐò¡£
²½Öè5£º×îºóÒ»²½£¬ÔÚÓ¦ÓóÌÐòÖÐʹÓÃjdbc driver classµÄʱºò£¬Ê¹ÓÃÈçÏÂÇý¶¯³ÌÐò£º
net.sourceforge.jdbclogger.JdbcLoggerDriver
Ìáʾ£ºÕâ¸öÊǹ̶¨µÄ£¬Óë¾ßÌåÊý¾Ý¿âÎ޹ء£
OK¡£ÏÂÃæ²âÊÔһϣ¬¾ÍÄÜ¿´µ½jdbc loggerÊä³öµÄÈÕÖ¾ÁË¡£
Ïà¹ØÎĵµ£º
MySQLµ¼³öºÍµ¼ÈëSQL½Å±¾
µ¼³ösql½Å±¾£º
mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > ´æ·ÅλÖÃ
mysqljump -u root -p test > c:\a.sql
µ¼Èësql½Å±¾£º
Òª½¨»·¾³±äÁ¿»òÕßÔÚbinµÄĿ¼Ï£¬mysqlÕâ¸öÃüÁî²ÅÄÜʶ±ð¡£
testÊÇÄãÒªµ¼½øÈ¥µÄÊý¾Ý¿âÃû×Ö£¬ÒªÌáÇ°½¨ºÃ~~
mysql -u Óû§Ãû -p Êý¾Ý¿âÃû < ´æ·ÅλÖÃ
mysqljump -u ro ......
Ò»Ö±ÒÔÀ´¶ÔÓÚSQLµÄ²éѯ¶¼Ã»ÔõôÔÚÒ⣬½ñÌìÓöµ½Ò»¸ö¹ØÓÚ×óÁ¬½Ó²éѯµÄÎÊÌâ¡£
Select uId ,uName,dpName
from users
left join dpart
on users.pid=1 where u.pid=dpart.pid
½á¹ûÊÇ°ÑusersËùÓнá¹û²éѯ³öÀ´£¬¶ø²»ÊÇpidΪ1µÄÓû§
ÔÀ´onºóÃæ±ØÐë·ÅÁ¬½ÓÌõ¼þ£¬ÆäËûµÄÌõ¼þ·ÅÔÚwhereÀïÃæ
¸ÐлÏÄ»¶Ìá³ö ......
×òÌìÎÒ˵£¬ÓÃ×éºÏË÷ÒýÓÅ»¯SQL£¬²¢²»ÊÇ×îÓŵģ¬ÕâÊÇÒòΪÔÚ8ÒڵıíÉÏÃæÓиöµÈ¼ÛµÄÎﻯÊÓͼ£¬Õâ¸öÎﻯÊÓͼ¿ÉÒÔ´úÌæÎÒÔÚ֮ǰÔÚ±íÉÏÃ潨Á¢µÄ×éºÏË÷Òý¡£
SQL> explain plan for SELECT distinct * from (select
2 (PROD_9005_GDF_WK_SS_FDIM.PROD_4_NAME),
3 PROD_9005_GDF_WK ......
Ò»°ãµÄ¹«Ë¾Í¨³£»áÔÚËûÃǵÄÐÅϢϵͳ¼Ü¹¹ÖÐÒýÈë¶àÖÖÊý¾Ý¿âƽ̨£¬Í¬Ê±ÒýÈëÈýµ½ËÄÖÖ²»Í¬µÄRDBMS½â¾ö·½°¸µÄÖдóÐ͹«Ë¾Ò²²¢²»ÉÙ¼û£¬µ±È»ÕâЩ¹«Ë¾ÀïÃæµÄDBAÃÇͨ³£Ò²ÐèҪͬʱӵÓйÜÀí¶àÖÖ²»Í¬Æ½Ì¨µÄ¼¼ÄÜÁË¡£
Ö»ÔÚÒ»ÖÖƽ̨ÉÏÕ¹¿ª¹¤×÷µÄÊý¾Ý¿âר¼ÒÃÇҲͨ³£»áÆÚ´ý×ÅÔÚËûÃǵÄÏÂÒ»·Ý¹¤×÷ÖÐÄÜѧµ½µã²»Ò»ÑùµÄ¶«Î÷£¬ÄÇЩÓÐÓÂÆøµÄÈËÃÇÔòÔ¸Òâ ......
ÎÊÌâ±³¾°£º
¡¡¡¡ÈÕ³£¶ÔSql Server 2005¹ØϵÊý¾Ý¿â½øÐвÙ×÷ʱ£¬ÓÐʱ¶ÔÊý¾Ý¿â£¨È磺SharepointÍøÕ¾ÅäÖÃÊý¾Ý¿âÃû
Sharepoint_Config£©½øÐÐЩ²»Õý³£²Ù×÷ÈçÊý¾Ý¿âÔÚ¶Áдʱ¶øÎÞ¹ÊÍ£Ö¹Êý¾Ý¿â£¬´Ó¶øµ¼ÖÂSql Server 2005Êý¾Ý¿â²»Õý³£
Öжϣ¬µ±Ôٴδò¿ªÊý¾Ý¿âʱ»á·¢ÏÖijЩÊý¾Ý¿â»á±»±ê¼ÇΪ“¿ÉÒÉ”£¨suspect)£¬¼´ÔÚÊý¾ ......