新聞中心
MySQL設置當前時間為默認值的問題我們經常會遇到,下面就為您介紹MySQL設置當前時間為默認值的實現(xiàn)全步驟,希望對您能有所啟迪。

十載的湯原網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網營銷的優(yōu)勢是能夠根據用戶設備顯示端的尺寸不同,自動調整湯原建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“湯原網站設計”,“湯原網站推廣”以來,每個客戶項目都認真落實執(zhí)行。
數(shù)據庫:test_db1
創(chuàng)建表:test_ta1
兩個字段:id (自增 且為主鍵),
createtime 創(chuàng)建日期(默認值為當前時間)
方法一、是用alert table語句:
- use test_db1;
- create table test_ta1(
- id mediumint(8) unsigned not nulll auto_increment,
- createtime datetime,
- primary key (id)
- )engine=innodb default charset=gbk;
- alert table test_ta1 change createtime createtime timestamp not null default now();
方法二、直接創(chuàng)建方便:
- use test_db1;
- create table test_ta1(
- id mediumint(8) unsigned not nulll auto_increment,
- createtime timestamp not null default current_timestamp,
- primary key (id)
- )engine=innodb default charset=gbk;
方法三、可視化工具如 mysql-front
右擊createtime屬性
把Type屬性值改為timestamp
default 屬性選擇
以上就是MySQL設置當前時間為默認值的方法介紹。
【編輯推薦】
MySQL分表處理的實現(xiàn)方法
MySQL授權表使用示例
MySQL多表刪除的實現(xiàn)
MySQL獨立表空間的優(yōu)缺點
mysql數(shù)據庫大小寫的問題討論
名稱欄目:MySQL設置當前時間為默認值的方法
URL網址:http://www.dlmjj.cn/article/dpdsopj.html


咨詢
建站咨詢
