Mysql ÈÕÆÚºÍʱ¼äת»»º¯Êý´óÈ«
¶ÔÓÚÿ¸öÀàÐÍÓµÓеÄÖµ·¶Î§ÒÔ¼°²¢ÇÒÖ¸¶¨ÈÕÆÚºÎʱ¼äÖµµÄÓÐЧ¸ñʽµÄÃèÊö¼û7.3.6 ÈÕÆÚºÍʱ¼äÀàÐÍ¡£
ÕâÀïÊÇÒ»¸öʹÓÃÈÕÆÚº¯ÊýµÄÀý×Ó¡£ÏÂÃæµÄ²éѯѡÔñÁËËùÓмǼ£¬Æädate_colµÄÖµÊÇÔÚ×îºó30ÌìÒÔÄÚ£º
mysql> SELECT something from table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) select DAYOFWEEK('1998-02-03');
-> 3
WEEKDAY(date)
·µ»ØdateµÄÐÇÆÚË÷Òý(0=ÐÇÆÚÒ»£¬1=ÐÇÆÚ¶þ, ……6= ÐÇÆÚÌì)¡£
mysql> select WEEKDAY('1997-10-04 22:23:00');
-> 5
mysql> select WEEKDAY('1997-11-05');
-> 2
DAYOFMONTH(date)
·µ»ØdateµÄÔ·ÝÖÐÈÕÆÚ£¬ÔÚ1µ½31·¶Î§ÄÚ¡£
mysql> select DAYOFMONTH('1998-02-03');
-> 3
DAYOFYEAR(date)
·µ»ØdateÔÚÒ»ÄêÖеÄÈÕÊý, ÔÚ1µ½366·¶Î§ÄÚ¡£
mysql> select DAYOFYEAR('1998-02-03');
-> 34
MONTH(date)
·µ»ØdateµÄÔ·ݣ¬·¶Î§1µ½12¡£
mysql> select MONTH('1998-02-03');
-> 2
DAYNAME(date)
·µ»ØdateµÄÐÇÆÚÃû×Ö¡£
mysql> select DAYNAME("1998-02-05");
-> 'Thursday'
MONTHNAME(date)
·µ»ØdateµÄÔ·ÝÃû×Ö¡£
mysql> select MONTHNAME("1998-02-05");
-> 'February'
QUARTER(date)
·µ»ØdateÒ»ÄêÖеļ¾¶È£¬·¶Î§1µ½4¡£
mysql> select QUARTER('98-04-01');
-> 2
WEEK(date)
¡¡
WEEK(date,first)
¶ÔÓÚÐÇÆÚÌìÊÇÒ»ÖܵĵÚÒ»ÌìµÄµØ·½£¬ÓÐÒ»¸öµ¥¸ö²ÎÊý£¬·µ»ØdateµÄÖÜÊý£¬·¶Î§ÔÚ0µ½52¡£2¸ö²ÎÊýÐÎʽWEEK()ÔÊÐí
ÄãÖ¸¶¨ÐÇÆÚÊÇ·ñ¿ªÊ¼ÓÚÐÇÆÚÌì»òÐÇÆÚÒ»¡£Èç¹ûµÚ¶þ¸ö²ÎÊýÊÇ0£¬ÐÇÆÚ´ÓÐÇÆÚÌ쿪ʼ£¬Èç¹ûµÚ¶þ¸ö²ÎÊýÊÇ1£¬
´ÓÐÇÆÚÒ»¿ªÊ¼¡£
mysql> select WEEK('1998-02-20');
-> 7
mysql> select WEEK('1998-02-20',0);
-> 7
mysql> select WEEK('1998-02-20',1);
-> 8
YEAR(date)
·µ»ØdateµÄÄê·Ý£¬·¶Î§ÔÚ1000µ½9999¡£
mysql> select YEAR('98-02-03');
-> 1998
HOUR(time)
·µ»ØtimeµÄСʱ£¬·¶Î§ÊÇ0µ½23¡£
mysql> select HOUR('10:05:03');
-> 10
MINUTE(time)
·µ»ØtimeµÄ·ÖÖÓ£¬·¶Î§ÊÇ0µ½59¡£
mysql> select MINUTE('98-02-03 10:05:03');
-> 5
SECOND(time)
»ØÀ´timeµÄÃëÊý£¬·¶Î§ÊÇ0µ½59¡£
mysql> select SECOND('10:05:03');
-> 3
PERIOD_ADD(P,N)
Ôö¼ÓN¸öÔµ½½×¶ÎP£¨ÒÔ¸ñʽYYMM»òYYYYMM)¡£ÒÔ¸ñʽYYYYMM·
Ïà¹ØÎĵµ£º
ÎҵijÌÐòÊÇÓÃADOÀ´Á¬½ÓMysqÊý¾Ý¿âµÄ£¬ÕâÊÇÔÏÈдºÃÓÃÔÚMSSQLÉϵģ¬¸ÄÁËÏÂÁ¬½Ó×Ö·û´®£¬ËùÒÔÒ²¾ÍûÓÐÓÃMySql C++ APIÀ´ÖØÐÂдÁË¡£¸Õ¿ªÊ¼Ê¹ÓÃMySql£¬Óöµ½µÄÎÊÌâ×ÜÊÇÌرðµÄ¶à£¬ÏÖÔÚÓÖÓöµ½Ò»¸öÖ÷Òªsql×Ö·û´®ÖÐÓÐÖÐÎľͱ¨´íµÄÎÊÌ⣬ûÓÐÖÐÎÄÒ»ÇÐÕý³££¬ÕûÕûŪÁËÒ»¸öÉÏÎ磬ÔÚÍøÉÏÒ²ÕÒÁ˺ܶà×ÊÁÏ£¬·¢ ......
mysql text ³¤¶È
ÎÄÕ·ÖÀà:Êý¾Ý¿â
½ñÌìÔÚ×öDBÉè¼ÆµÄʱºòÔÚÏëÓÃTEXT ÊÇ·ñÄܹ»Âú×㽫À´µÄÊý¾Ý£¬Äܹ»³öÏÖ×°²»ÏµÄÇé¿ö¡£
ºóÀ´²éѯÁËһϹٷ½ÊÖ²áµÃµ½ÁËÒ»¸ö´ð°¸¡£
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ65535(2^16-1)¸ö×Ö·û¡£
MEDIUMBLOB
MEDIUMTEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ16777215(2^24-1)¸ö×Ö·û¡£
LONG ......
mysql> explain select count(id) from t_prehandle_zhigao_05 as zhigao where start_time > '2008-05-30';
+----+-------------+--------+-------+---------------+------------+---------+------+---------+--------------------------+
| id | select_type | table | type | p ......
ÓÒ¼üÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿
¿ÉÒÔ¿´µ½ÓÐÓû§±äÁ¿ºÍϵͳ±äÁ¿
ÔÚÕâÀïÎÒÃÇ¿ÉÒÔ½øÐÐÐ޸Ļ·¾³±äÁ¿
±ÈÈç˵ÎÒÃÇ°²×°ÁËMySQL·þÎñÆ÷£¬Ïë½øÈëMySQLµÄÃüÁîÐеĻ°¾Í±ØÐëÔËÐÐcmd
Èç¹ûûÓÐÉèÖû·¾³±äÁ¿µÄ»°ÎÒÃDZØÐë½øÈëMySQLµÄ°²×°Â·¾¶²ÅÄÜʹÓÃmysql -u root -pÕâ¸öÃüÁî
ÕâÑù»á¸øÎÒÃÇ´øÀ´ºÜ¶àÂé·³£¬ÕâʱºòÎÒÃÇÏëÔ ......
ÈçÈôתÔر¾ÎÄ£¬Çë×¢Ã÷Ôʼ³ö´¦£ºhttp://hi.baidu.com/hexiong/blog/item/e860e5dd9b0d3ae376c6381a.html
(hexiong@baidu or iihero@CSDN)
ż¶ûÅöµ½ÓÐÈËÎÊʹÓÃmysqlÃüÁîÐУ¬ÀÏÈÃÈËÊäÈë--default-character-set=gbkÖ®ÀàÎÞÁĵÄÑ¡ÏÈÃÈË·³¡£ÈÃÈ˶àÊäÈëÁ˼¸¸ö×Ö·û£¬È·ÊµÓе㲻¶Ô¾¢¡£
¼ÓÉÏÓÐʱºò×Ô¼ºÓÐʱºòDIY£¬ºÜÉÙÔÚwindow ......