解析MySQL設置當前時間為默認值的方法
更新時間:2013年06月14日 11:15:48 作者:
本篇文章是對MySQL設置當前時間為默認值的方法進行了詳細的分析介紹,需要的朋友參考下
MySQL設置當前時間為默認值的問題我們經常會遇到,下面就為您介紹MySQL設置當前時間為默認值的實現全步驟,希望對您能有所啟迪。
數據庫: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 屬性選擇<INSERT-TimeStamp>
以上就是MySQL設置當前時間為默認值的方法介紹。
相關文章
Starting MySQL.Manager of pid-file quit without updating fil
因為硬盤滿了,Starting MySQL.Manager of pid-file quit without updating file.[FAILED]2010-02-02
關于mysql create routine 權限的一些說明
下面小編就為大家?guī)硪黄P于mysql create routine 權限的一些說明。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03
在Mac系統(tǒng)上配置MySQL以及Squel Pro
給大家講述一下如何在MAC蘋果系統(tǒng)上配置MYSQL數據庫以及Squel Pro的方法。2017-11-11
Windows服務器下MySql數據庫單向主從備份詳細實現步驟分享
將主服務器中的MySql數據庫同步到從服務器中,使得對主服務器的操作可以即時更新到從服務器,避免主服務器因環(huán)境或者網絡異常一時無法使用,達到備份效果,這篇文章整理的確實挺詳細的2012-05-05

