MySQLµÄtimestampÀàÐÍ×Ô¶¯¸üÐÂÎÊÌâ
×¢£º±¾ÎÄÌÖÂ۵ķ¶Î§ÎªÎ´ÆôÓÃMAXDBģʽµÄ±í£¡
½ñÌ콨ÁËÒ»¸ö±í£¬ÀïÃæÓÐÒ»¸öÁÐÊÇtimestampÀàÐÍ£¬ÎÒ±¾ÒâÊÇÔÚÊý¾Ý¸üÐÂʱ£¬Õâ¸ö×ֶεÄʱ¼äÄÜ×Ô¶¯¸üС£ÆñÖª¶ÔÕâ¸öÀàÐ͵ÄÖµ»¹²»ÉõÁ˽⣬µ¼Ö³ö´í¡£·¢ÏÖÕâ¸ö×Ö¶ÎÖ»ÊÇÔÚÕâÐÐÊý¾Ý½¨Á¢µÄʱºòÓÐÖµ£¬ÔÚ¸üеÄÈ´Îޱ仯¡£
²éÕÒ×ÊÁÏ£¬·¢ÏÖÊÇÎÒ½¨±íµÄÓï¾äÓÐÎÊÌ⣺
ÒÔÏÂÊÇ´úÂëƬ¶Î£º
CREATE TABLE `test` (
`t1` timestamp NOT NULL default CURRENT_TIMESTAMP,
`ww` varchar(5) NOT NULL
) ENGINE=MyISAM ;
¶øʵ¼ÊÉÏ£¬ÒÔÏÂÁ½¸ö½¨±íÓï¾äµÄЧ¹ûÊÇÒ»ÑùµÄ£º
ÒÔÏÂÊÇ´úÂëƬ¶Î£º
CREATE TABLE `test` (
`t1` TIMESTAMP NOT NULL ,
`ww` VARCHAR( 5 ) NOT NULL
) ENGINE = MYISAMCREATE TABLE `test` (
`t1` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ww` varchar(5) NOT NULL
) ENGINE=MyISAM ;
±È½Ï֮ϣ¬ÎÒµÄÓï¾äÉÙÁË“on update CURRENT_TIMESTAMP”»ò¶àÁË“default CURRENT_TIMESTAMP”¡£Èç´ËÒ»À´£¬Õâ¸ötimestamp×Ö¶ÎÖ»ÊÇÔÚÊý¾ÝinsertµÄʱ¼ä½¨Á¢Ê±¼ä£¬¶øupdateʱ¾Í²»»áÓб仯ÁË¡£µ±È»£¬Èç¹ûÄã¾ÍÊÇÏë´ïµ½Õâ¸öÄ¿µÄµ¹Ò²ÎÞËùν¡£
²éÕÒÓ¢ÎÄÊֲᣨhttp://dev.mysql.com/doc/refman/5.1/en/timestamp.html£©£¬µÃµ½¸üÏêϸµÄ½â˵£¬·ÒëÈçÏ£º
———————————–·Ò뿪ʼ——————————–
ÔÚCREATE TABLEÓï¾äÖУ¬µÚ1¸öTIMESTAMPÁпÉÒÔÓÃÏÂÃæµÄÈκÎÒ»ÖÖ·½Ê½ÉùÃ÷£º
1£º Èç¹û¶¨ÒåʱDEFAULT CURRENT_TIMESTAMPºÍON UPDATE CURRENT_TIMESTAMP×Ӿ䶼ÓУ¬ÁÐֵΪĬÈÏʹÓõ±Ç°µÄʱ¼ä´Á£¬²¢ÇÒ×Ô¶¯¸üС£
2£º Èç¹û²»Ê¹ÓÃDEFAULT»òON UPDATE×Ӿ䣬ÄÇôËüµÈͬÓÚDEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP¡£
3£º Èç¹ûÖ»ÓÐDEFAULT CURRENT_TIMESTAMP×Ӿ䣬¶øûÓÐON UPDATE×Ӿ䣬ÁÐֵĬÈÏΪµ±Ç°Ê±¼ä´Áµ«²»×Ô¶¯¸üС£
4£º Èç¹ûûÓÃDEFAULT×Ӿ䣬µ«ÓÐON UPDATE CURRENT_TIMESTAMP×Ӿ䣬ÁÐĬÈÏΪ0²¢×Ô¶¯¸üС£
5£º Èç¹ûÓÐÒ»¸ö³£Á¿
Ïà¹ØÎĵµ£º
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
¸ÃÓï¾äÄÜ´´½¨ÐµÄÊÓͼ£¬Èç¹û¸ø¶¨ÁËOR REPLACE×Ӿ䣬¸ÃÓï¾ä»¹ÄÜÌæ»»ÒÑÓеÄÊÓͼ¡£s ......
ÍêÕûµÄʵÏÖÁËPHP½«Í¼Æ¬´æÈëMYSQL
Ç°Ì᣺
1 Ê×ÏȱØÐëÓµÓÐPHPµÄÔËÐл·¾³£¬ÁíÍ⻹µÃÓÐMYSQLÊý¾Ý¿â
2 Èç¹ûÎļþ²»ÄÜÉÏ´«³É¹¦Çë¼ì²épicsÊÇ·ñÊÇ¿ÉдµÄȨÏÞ
Ê×ÏÈÏÈ°Ñpic2db.rarÎļþ½âѹµ½PHP¿ÉÒÔÔËÐÐĿ¼Ï¡£
Æä´ÎÔÚMYSQLÖн¨Á¢Ò»¸öÊý¾Ý¿â:pic2db,È»ºóÔÚ¸ÃÊý¾Ý¿âϽ¨Á¢Ò»¸ö±í£¬±í½á¹¹Îª£º
CREATE TABLE `pi ......
mysql°²×°Í¼½â½Ì³Ì 5.1
2009Äê03ÔÂ01ÈÕ ÐÇÆÚÈÕ 23:51
תÔØÇë×¢Ã÷³ö´¦:http://hi.baidu.com/herdff/blog/item/6e6b4bcf6132f90b93457e14.html
±¾½Ì³ÌÒÔMysql 5.1°æ±¾ÎªÀý£¬¸ü¸ß°æ±¾°²×°¹ý³ÌÓë´ËÀàËÆ¡£ÔĶÁÇ°£¬ÇëÏÂÔØ5.1£¬ÏÂÔصØÖ·£ºwww.mysql.com
°²×°¹ý³ÌÓëÆäËüWindows°²×°³ÌÐòÒ»Ñù£¬Ê×ÏȳöÏÖµÄÊÇ°²×°Ïòµ¼»¶Ó½çÃæ
Ö ......
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
¸ÃÓï¾äÄÜ´´½¨ÐµÄÊÓͼ£¬Èç¹û¸ø¶¨ÁËOR REPLACE×Ӿ䣬¸ÃÓï¾ä»¹ÄÜÌæ»»ÒÑÓеÄÊÓͼ¡£select_st ......
Èç¹ûÒ»¸öMyISAM±í°üº¬Èκοɱ䳤¶ÈÁУ¨VARCHAR, BLOB»òTEXTDynamic£©£¬»òÕßÈç¹ûÒ»¸ö±í±»ÓÃROW_FORMAT=DYNAMICÑ¡ÏîÀ´´´½¨£¬¶¯Ì¬´æ´¢¸ñʽ±»Ê¹Óá£
Õâ¸ö¸ñʽ¸üΪ¸´ÔÓÒ»µã£¬ÒòΪÿÐÐÓÐÒ»¸ö±íÃ÷ÐÐÓж೤µÄÍ·¡£µ±Ò»¸ö¼Ç¼ÒòΪ¸üеĽá¹û±»±äµÃ¸ü³¤£¬¸Ã¼Ç¼Ҳ¿ÉÒÔÔÚ³¬¹ýÒ»¸öλÖô¦½áÊø¡£
Äã¿ÉÒÔʹÓÃOPTIMIZE TAB ......