mysql ÖРʱ¼äºÍÈÕÆÚº¯Êý
»ù´¡²¿·Ö
Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µÄÈÕÆÚʱ¼äÍ⣬MySQL Öл¹ÓÐÏÂÃæµÄº¯Êý£º
current_timestamp()
,current_timestamp
,localtime()
,localtime
,localtimestamp -- (v4.0.6)
,localtimestamp() -- (v4.0.6)
ÕâЩÈÕÆÚʱ¼äº¯Êý£¬¶¼µÈͬÓÚ now()¡£¼øÓÚ now() º¯Êý¼ò¶ÌÒ׼ǣ¬½¨Òé×ÜÊÇʹÓà now() À´Ìæ´úÉÏÃæÁгöµÄº¯Êý¡£
1.2 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºsysdate()
sysdate() ÈÕÆÚʱ¼äº¯Êý¸ú now() ÀàËÆ£¬²»Í¬Ö®´¦ÔÚÓÚ£ºnow() ÔÚÖ´ÐпªÊ¼Ê±Öµ¾ÍµÃµ½ÁË£¬ sysdate() ÔÚº¯ÊýÖ´ÐÐʱ¶¯Ì¬µÃµ½Öµ¡£¿´ÏÂÃæµÄÀý×Ó¾ÍÃ÷°×ÁË£º
mysql> select now(), sleep(3), now();
+---------------------+----------+---------------------+
| now() | sleep(3) | now() |
+---------------------+----------+---------------------+
| 2008-08-08 22:28:21 | 0 | 2008-08-08 22:28:21 |
+---------------------+----------+---------------------+
mysql> select sysdate(), sleep(3), sysdate();
+---------------------+----------+---------------------+
| sysdate() | sleep(3) | sysdate() |
+---------------------+----------+---------------------+
| 2008-08-08 22:28:41&nbs
Ïà¹ØÎĵµ£º
ÔÚÉú²úÓ¦ÓÃÖУ¬Ä³Ì¨“Nginx+PHP+MySQL”½Ó¿ÚÊý¾Ý·þÎñÆ÷£¬°çÑݵĽÇÉ«Ê®·ÖÖØÒª£¬Èç¹û·þÎñÆ÷Ó²¼þ»òNginx¡¢MySQL·¢Éú¹ÊÕÏ£¬¶ø ¶Ìʱ¼äÄÚÎÞ·¨»Ö¸´£¬ºó¹û½«·Ç³£ÑÏÖØ¡£ÎªÁ˱ÜÃâµ¥µã¹ÊÕÏ£¬ÎÒÉè¼ÆÁË´ËÌ×·½°¸£¬±àдÁËfailover.sh½Å±¾£¬ÊµÏÖÁËË«»ú»¥±¸¡¢È«×Ô¶¯Çл»£¬¹ÊÕÏתÒÆʱ¼ä Ö»Ð輸ʮÃë¡£
Ò»¡¢Ë«»ú»¥±¸¡¢È«×Ô¶¯Çл»·½°¸ ......
ת×Ô http://www.supidea.com/post/mysql_design_database.aspx
MySQLÊý¾Ý¿âÉè¼ÆÔÔò
MySQL¶ÔÓÚ³ÉΪһ¸ö·Ç³£¿ìËÙµÄÊý¾Ý¿â·þÎñÆ÷ÓÐ×ŵ±Ö®ÎÞÀ¢µÄÃûÉù£¬ËüÒ²·Ç³£ÈÝÒ×ÉèÖúÍʹÓá£Ëæ×ÅËü×÷ΪÍøÕ¾ºó¶ËÊý¾Ý¿âµÃÉùÍûÈÕÔö£¬ÆäЧ¹ûÔÚÈ¥Ä꿪ʼÓÐÃ÷ ÏÔÌá¸ß¡£µ«ÊǺܶàMySQLÓû§¸ü¶àµØÖªµÀÈçºÎ´´½¨Ò»¸öÊý¾Ý¿â²¢±àд¶ÔËüµÄ²éѯ¡£¾ÍÏñ³ÉÇ ......
1£¬Mysql²åÈë¶þ½øÖÆ´ó¶ÔÏó³öÏÖÒì³££¬²åÈë¶þ½øÖƳöÏÖÒì³££¬Ôõô½â¾öcom.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
½â¾ö°ì·¨£ºurl=url=+"?useUnicode=true& ......
mysql
> SHOW VARIABLES LIKE
'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection |
latin1 |
| character_set ......
ÔÚÊý¾Ý¿âÓ¦Óã¬ÎÒÃǾ³£ÒªÓõ½Î¨Ò»±àºÅ¡£ÔÚMySQLÖпÉͨ¹ý×ֶεÄAUTO_INCREMENTÊôÐÔÀ´×Ô¶¯Éú³É¡£MySQLÖ§³Ö¶àÖÖÊý¾Ý±í£¬Ã¿ÖÖÊý¾Ý±íµÄ×ÔÔöÊôÐÔ¶¼ÓÐËù²»Í¬¡£
ISAM±í
Èç¹û°ÑÒ»¸öNULL²åÈëµ½Ò»¸öAUTO_INCREMENTÊý¾ÝÁÐÀïÈ¥£¬MySQL½«×Ô¶¯Éú³ÉÏÂÒ»¸öÐòÁбàºÅ¡£±àºÅ´Ó1¿ªÊ¼£¬²¢1Ϊ»ùÊýµÝÔö¡£
µ±²åÈë¼Ç¼ʱ£¬Ã»ÓÐΪAUTO_INCREMENTÃ÷È ......