MySQL5.6時間類型timestamp和datetime有了重大改變

來源:互聯網
上載者:User

在MySQL5.5裡或更老的版本MySQL5.1)timestamp類型一個表裡只允許一欄欄位擁有自動插入時間和自動更新時間、或只允許一欄欄位有自動插入時間,另一欄欄位不能有自動更新時間。 但從MySQL5.6裡,打翻了這一傳統理念,以上條件均可以出現,並且datetime類型也擁有了timestamp類型的功能。 以下是示範: 這是MySQL5.5的timestamp類型一個表裡只允許一欄欄位擁有自動插入時間和自動更新時間):

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/192340GV-0.jpg" alt="" /> 650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923402G8-1.jpg" alt="" />

========================================================================

這是MySQL5.6的timestamp類型一個表裡可以有多欄欄位擁有自動插入時間和自動更新時間):

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/192340B36-2.jpg" alt="" /> 650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923401L4-3.jpg" alt="" />

========================================================================

這是MySQL5.5的只允許一欄欄位有自動插入時間,另一欄欄位不能有自動更新時間)

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923403410-4.jpg" alt="" />

========================================================================

這是MySQL5.6的一欄欄位有自動插入時間,另一欄欄位也能有自動更新時間)

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923406264-5.jpg" alt="" /> 650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/192340H93-6.jpg" alt="" />

========================================================================

MySQL5.6datetime類型也擁有了timestamp類型的功能)

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923401149-7.jpg" alt="" /> 650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/192340G25-8.jpg" alt="" />

========================================================================

參考手冊:

650) this.width=650;" border="0" src="http://www.bkjia.com/uploads/allimg/131229/1923405W7-9.jpg" alt="" />

 

本文出自 “賀春暘的技術專欄” 部落格,請務必保留此出處http://hcymysql.blog.51cto.com/5223301/1007310

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.