MySQL£ºÈÕÆÚº¯Êý¡¢Ê±¼äº¯Êý×ܽᣨMySQL 5.X£©
MySQL£ºÈÕÆÚº¯Êý¡¢Ê±¼äº¯Êý×ܽᣨMySQL 5.X£©
²Î¿¼³¤ÎÄ£º
Ò»¡¢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 | 0 | 2008-08-08 22:28:44 |
+---------------------+----------+---------------------+
¿ÉÒÔ¿´µ½£¬ËäÈ»ÖÐ; sleep 3 Ã룬µ« now() º¯ÊýÁ½´ÎµÄʱ¼äÖµÊÇÏàͬµÄ£» sysdate() º¯ÊýÁ½´ÎµÃµ½µÄʱ¼äÖµÏà²î 3 Ãë¡£MySQL Manual ÖÐÊÇÕâÑùÃèÊö sysdate() µÄ£ºReturn the time at which the function executes¡£
sysdate() ÈÕÆÚʱ¼äº¯Êý£¬Ò»°ãÇé¿öϺÜÉÙÓõ½¡£
2. »ñµÃµ±Ç°ÈÕÆÚ£¨date£©º¯Êý£ºcurdate()
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2008-08-08 |
+------------+
ÆäÖУ¬ÏÂÃæµÄÁ½¸öÈÕÆÚº¯ÊýµÈͬÓÚ curdate()£º
current_date()
,current_date
3. »ñµÃµ±Ç°Ê±¼ä£¨time£©º¯Êý£ºcurtime()
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 22:41:30 |
+-----------+
ÆäÖУ¬ÏÂÃæµÄÁ½¸öʱ¼
Ïà¹ØÎĵµ£º
ÔÚVC6ÖÐʹÓÃc API·½Ê½Á¬½ÓMySQLÊý¾Ý¿â
Ò»¡¢»·¾³ÅäÖÃ
1¡¢ÔÚMySqlµÄ¹Ù·½ÍøÕ¾ÏÂÔØmysql-connector-c-noinstall£¬²¢½«½âѹºóµÄbinºÍincludeÎļþ¼Ð¿½±´µ½MysqlµÄ°²×°Ä¿Â¼
2¡¢ÉèÖÃVC6»·¾³£¬ÔÚvc¹¤¾ß-Ñ¡Ïî-Ŀ¼£¬¼ÓÈë¸Õ²ÅµÄIncludeÎļþ¼ÐµÄ·¾¶£¬ÀýÈ磺C:\Program Files\MySQL\MySQL Server 5.1\include
¶þ¡¢¹¤³ÌÉèÖÃ
3¡¢½«li ......
MYSQLÃüÁî´óÈ«
Ò»¡¢Á¬½ÓMYSQL¡£
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £pÓû§ÃÜÂë
1¡¢Á¬½Óµ½±¾»úÉϵÄMYSQL¡£Ê×ÏÈ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼mysql\bin£¬ÔÙ¼üÈëÃüÁîmysql -u root -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂë.×¢ÒâÓû§ÃûÇ°¿ÉÒÔÓпոñÒ²¿ÉÒÔûÓпոñ£¬µ«ÊÇÃÜÂëÇ°±ØÐëûÓпոñ£¬·ñÔòÈÃÄãÖØÐÂÊäÈëÃÜÂë. Èç¹û¸Õ°²×°ºÃMYSQL£¬³¬¼¶Óû ......
ÐÞ¸ÄrootÃÜÂëµÄʱºò°´ÕÕÍøÉϵÄ˵µÄ¾ÓȻɵɵµÄÖ´ÐÐÁËupdate user set password="asdf" where user="root"£»Ö´ÐÐÖ®ºó·¢ÏÖÃÜÂë´íÁË£¬½øÈ¥²»ÁË£¬ÓÚÊÇÕÛÌÚÁË°ëÌ죬·¢ÏÖmysqlµÄÃÜÂëÊǼÓÃܵIJ»ÊÇÃ÷ÎÄ´æ´¢µÄ£¬ËùÒԸĵÄʱºòÐèÒªÕâÑùset password=password("asdf")¡£´íÎóÒѾ·¢ÉúÁË£¬ÓÚÊǾͰ´ÕÕÏÂÃæµÄ· ......
½â¾öMySqlÊý¾ÝÂÒÂë:
1 д¹ýÂËÆ÷ÉèÖñàÂë¸ñʽ(¸ñʽºÍJSPÒ³ÃæµÄ±àÂëÒ»Ñù)£¬»òÔòÔÚÇëÇóÀïÃæдrequest.setCharacterEncoding("±àÂ뷽ʽ");
2 Èç¹ûÊDzéѯ³öÊý¾ÝÂÒÂ룬ÔÚÁ´½ÓµÄURLÉϼÓÉϱàÂë¸ñʽ(ÄãÕâÀï¼ÓÁË£¬Ã»ÎÊÌâ);
3 ÐÞ¸Ämy.iniÎļþÀïÃæµÄ default-character-set= ÄúÒªµÄ±àÂë¸ñʽ (Ò»¹²ÓÐÁ½´¦£¬Äã²éÕÒһϠ¸ÄΪһÑùµÄ±à ......
Èç¹ûÒªËæ»ú»ñÈ¡¼Ç¼Êý£¬ÔÚmysqlÀï×î¼òµ¥µÄ·½·¨¿Ï¶¨ÊÇorder
by
rand
()ÁË£¬µ«ÊÇÕâÖÖ·½·¨Ö»ÄÜÔÚ±í¼Ç¼¼«ÉÙµÄÇé¿öϲÅÄÜʹÓá£Ö÷ÒªÊÇÒòΪorder
by
rand
()µ¼ÖÂÁËusing filesort.Õâ¸öʱºò²éѯÀàÐÍ»á±ä³Éall£¬Ë÷Òý»áʧЧ¡£Ö»Ðè¼òµ¥µÄ±äͨÏ£¬Íê³É¿ÉÒÔ×öµ½Í¬ÑùµÄЧ¹û¡£
¸ù¾Ý¼Ç¼µÄÀàÐÍ£¬·ÖÀàÁ¬ÐøºÍ·ÇÁ¬ÐøÁ½ÖÖ¡£
Á¬ÐøÖ ......