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

MySQLÊý¾Ý¿âÉè¼ÆÔ­Ôò

ת×Ô http://www.supidea.com/post/mysql_design_database.aspx
MySQLÊý¾Ý¿âÉè¼ÆÔ­Ôò
MySQL¶ÔÓÚ³ÉΪһ¸ö·Ç³£¿ìËÙµÄÊý¾Ý¿â·þÎñÆ÷ÓÐ×ŵ±Ö®ÎÞÀ¢µÄÃûÉù£¬ËüÒ²·Ç³£ÈÝÒ×ÉèÖúÍʹÓá£Ëæ×ÅËü×÷ΪÍøÕ¾ºó¶ËÊý¾Ý¿âµÃÉùÍûÈÕÔö£¬ÆäЧ¹ûÔÚÈ¥Ä꿪ʼÓÐÃ÷ ÏÔÌá¸ß¡£µ«ÊǺܶàMySQLÓû§¸ü¶àµØÖªµÀÈçºÎ´´½¨Ò»¸öÊý¾Ý¿â²¢±àд¶ÔËüµÄ²éѯ¡£¾ÍÏñ³ÉǧÉÏÍòµÄÈËͨ¹ýÔØÏÐϾʱÓÃLinux×öʵÑéÀ´Ñ§Ï°UnixÄÇÑù£¬ºÜ ¶àÈËͨ¹ýÍæMySQLѧϰ¹ØϵÊý¾Ý¿â¡£ÕâЩMySQLÐÂÊֵĴó¶àÊý¼ÈûÓйØϵÊý¾Ý¿âÀíÂ۵ı³¾°£¬ÓÖûÓÐʱ¼äÔĶÁMySQLÊÖ²áÈ«ÎÄ¡£
    Òò´Ë£¬ÎÒÃǾö¶¨Ñо¿Ä³Ð©·½·¨£¬Äã¿ÉÒÔÓÃÕë¶ÔÓÅ»¯ÐÔÄÜÀ´µ÷½ÚMySQL¡£ÔÚ¶ÁÍê±¾Îĺó£¬Ä㽫Àí½âһЩ°ïÖúÄãÉè¼ÆÄãµÄMySQLÊý¾Ý¿âºÍ²éѯµÄ¼¼Êõ£¬ÖµµÃÄãµÄÓ¦ÓúÜÓÐЧÂÊ¡£ÎÒÃǽ«¼Ù¶¨ÄãÊìϤMySQLºÍSQL»ù´¡£¬µ«²»¼Ù¶¨ÄãÓÐÕâÁ½·½ÃæµÄ¹ã²©ÖªÊ¶¡£
    Ö»´æ´¢ÄãÐèÒªµÄÐÅÏ¢
    ÕâÌýÉÏÈ¥Êdz£Ê¶£¬µ«ÈËÃdz£³£²ÉÈ¡“³ø·¿ÏÂË®µÀ”µÄ·½Ê½½øÐÐÊý¾Ý¿âÉè¼Æ¡£ËûÃÇÈÏΪ¿ÉÄÜÏîÒªµÃÿÑù¶«Î÷¶¼Òª´æ´¢²¢Éè¼ÆÊý¾Ý¿â±£´æËùÓÐÕßÕâЩÊý¾Ý¡£ÄãÐèÒª¶ÔÄãµÄÐè ÇóÏÖʵЩ£¬²¢È·¶¨È¡È·ÊµÐèҪʲôÐÅÏ¢¡£Äã³£³£ÄÜËæÒâ²úÉúһЩÊý¾Ý¶ø²»°ÑËü´æÔÚÊý¾Ý¿â±íÖС£ÔÚÕâÖÖÇé¿öÏ£¬´ÓÒ»¸öÓ¦Óÿª·¢ÕߵĽǶȿ´Ò²ÓеÀÀíÕâÑù×ö¡£
    Àý È磬ÔÚÏßĿ¼µÄ²úÆ·±í¿ÉÄÜ°üº¬¸÷ÖÖ²úÆ·µÄÃû³Æ¡¢½éÉÜ¡¢³ß´ç¡¢ÖØÁ¿ºÍ¼Û¸ñ¡£³ýÁ˼۸ñ£¬Äã¿ÉÄÜÏë´æ´¢Ã¿¸öÏîÄ¿Ïà¹ØµÄË°ºÍÔËÊä³É±¾¡£µ«Êµ¼ÊÉϲ»±ØÕâÑù×ö¡£Ê×ÏÈË° ºÍÔËÊä³É±¾¿ÉÒÔ·½±ãµØ£¨ÓÉÄãµÄÓ¦ÓûòMySQL£©¼ÆËã³öÀ´¡£Æä´Î£¬Èç¹ûË°ºÍÔËÊä³É±¾¸Ä±äÁË£¬Äã¿ÉÄܱØÐë±àд±ØÒªµÄ²éѯ¸üÐÂÿ¸ö²úÆ·¼Ç¼ÖеÄË°ºÍÔËÊäµÄ·Ñ ÂÊ¡£
    ÓÐʱÈËÃÇÈÏΪÕâÌ«ÄѲ»ÄÜÔÚÒÔºóÍùÊý¾Ý¿â±íÖмÓÈë×ֶΣ¬ËùÒÔËûÃǸоõ²»µÃ²»¶¨Ò御¿ÉÄܶàµÄÁС£ÕâÊÇÃ÷ÏԵĸÅÄî´íÎó¡£ÔÚMySQLÖУ¬Äã¿ÉÒÔÓÃALTER TABLEÃüÁî·½±ãµØÐÞ¸Ä±í¶¨ÒåÒÔÊÊÓ¦Äã¸Ä±äµÄÐèÇó¡£
    ÀýÈ磬Èç¹ûÄãͻȻÈÏʶµ½ÄãÐèÒª¸øÄãµÄ²úÆ·±íÔö¼ÓÒ»¸ö¼¶±ðÁУ¨¿ÉÄÜÄãÏëÔÊÐíÓû§ÔÚÄãµÄĿ¼Öиø²úÆ·ÆÀ¼¶£©£¬Äã¿ÉÒÔÕâÑù×ö£º
    ALTER TABLE products ADD rank INTEGER
    Õâ¸øÄãµÄ²úÆ·±íÔö¼ÓÁËÒ»¸öÕûÊýÀàÐ͵ļ¶±ðÁУ¬ÄãÄÜÓÃALTER TABLE×öʲôµÄÍêÕû½éÉܲμûMySQLÊֲᡣ
    Ö»ÒªÇóÄãÐèÒªµÄ¶«Î÷--ÒªÇåÎú
    ¾ÍÏñ˵“Ö»´æ´¢ÄãÐèÒªµÄ¶«Î÷”ÄÇÑù£¬Õâ¿ÉÄÜ¿´À´Êdz£Ê¶£¬µ«ÕâÒ»µã


Ïà¹ØÎĵµ£º

ʹÓÃhibernateÓëmysqlʱÊý¾Ý²»ÄܲåÈëµÄÔ­Òò¼°½â¾ö°ì·¨

1.±³¾°     
      Ö®Ç°´ÓûÓùýhibernate£¬Òò´ËÔÚÍøÉÏËÑÁËÒ»ÏÂhibernate¿ìËÙÈëÃÅ·½ÃæµÄÐÅÏ¢£¬×îºóÎÒ°´ÕÕ¡¶Myeclipse Hibernate ¿ìËÙÈëÃÅ ÖÐÎÄ°æ¡·£¨CSDN£¬°Ù¶ÈÎĿⶼÓУ©Ò»ÎÄ¿ªÊ¼ÁËÎÒµÄhibernateÖ®Âã¨ÎªÏîÄ¿×ö¼¼Êõ×¼±¸£©¡£
      ÏÂÃ ......

ÐÞ¸ÄMYSQLµÄinnodb_log_file_sizeµ¼ÖµÄMYSQL±ÀÀ£


ÕâÁ½ÌìÕýÔÚ²âMYSQLµÄÐÔÄÜ£¬°´ÕÕMYSQLÎĵµÖÐÍƼöµÄÉèÖã¬ÐÞ¸ÄÁ˼¸¸öϵͳ±äÁ¿
innodb_buffer_pool_size=1G
innodb_log_file_size=250M
innodb_log_buffer_size=8M
½á¹ûMYSQL±ÀÁË¡£mysql¿Í»§¶ËÄܵǼ£¬µ«Ö»ÒªÖ´ÐÐÈκÎÃüÁmysqldÁ¢¿Ì±Àµô¡£
¿ªÊ¼»¹ÒÔΪÊÇinnodb_buffer_pool_sizeµÈ¼¸¸ö²ÎÊýÉèµÃÌ«´óÁË£¬¿ÉÊǵ÷ÕûÁ˼¸´Î¶ ......

MysqlÖ¸Á showÓ÷¨

MySQL showµÄÓ÷¨
   
a. show tables»òshow tables from database_name; // ÏÔʾµ±Ç°Êý¾Ý¿âÖÐËùÓбíµÄÃû³Æ
   b. show databases; // ÏÔʾmysqlÖÐËùÓÐÊý¾Ý¿âµÄÃû³Æ
   c. show columns from table_name from database_name; »òshow columns from database_name.table_name;  ......

mysql Óï¾äÓÅ»¯²éѯ

ÎÒÓõÄÊÇmysql5.0£¬
ÎÒ³ÌÐòÖÐÓõ½ÁËÒ»¾äsqlÊÇ
SQL code
select count(DISTINCT id) from Policyinfo p where p.filename not in
(select p2.filename from Policyreadinfo p2 where p2.reader='test')
µ«ÊÇÿ´ÎÔÚ³ÌÐòÖÐÿ´ÎÖ´ÐÐÕâ¾äsqlʱÍøÒ³¾ÍÌØÂý£¬Òª10¶àÃ룬¶øÕâ2¸ö±íµÄ¼Ç¼ÐÐÊýÒ²¾Í1000¶à¶øÒÑ£¬ÎÒ°ÑÕâ¾äsqlµ¥¶ÀÄ ......

MySQL Order ByË÷ÒýÓÅ»¯

ÔÚһЩÇé¿öÏ£¬MySQL¿ÉÒÔÖ±½ÓʹÓÃË÷ÒýÀ´Âú×ãÒ»¸ö ORDER BY »ò GROUP BY ×Ó¾ä¶øÎÞÐè×ö¶îÍâµÄÅÅÐò¡£¾¡¹Ü ORDER BY ²»ÊǺÍË÷ÒýµÄ˳Ðò׼ȷƥÅ䣬Ë÷Òý»¹ÊÇ¿ÉÒÔ±»Óõ½£¬Ö»Òª²»ÓõÄË÷Òý²¿·ÖºÍËùÓеĶîÍâµÄ ORDER BY ×Ö¶ÎÔÚ WHERE ×Ó¾äÖж¼±»°üÀ¨ÁË¡£ ¡¡¡¡Ê¹ÓÃË÷ÒýµÄMySQL Order By ¡¡¡¡ÏÂÁеļ¸¸ö²éѯ¶¼»áʹÓÃË÷ÒýÀ´½â¾ö ORDER BY ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ