国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

解析MySQL設置當前時間為默認值的方法

2020-01-18 23:39:40
字體:
來源:轉載
供稿:網友

MySQL設置當前時間為默認值的問題我們經常會遇到,下面就為您介紹MySQL設置當前時間為默認值的實現全步驟,希望對您能有所啟迪。
數據庫:test_db1
創建表:test_ta1
兩個字段:id              (自增 且為主鍵),
createtime 創建日期(默認值為當前時間)

方法一、是用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();

方法二、直接創建方便:
復制代碼 代碼如下:

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設置當前時間為默認值的方法介紹。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 荆门市| 武胜县| 玉门市| 丰顺县| 阳春市| 五原县| 怀集县| 新建县| 台东市| 古交市| 平潭县| 卫辉市| 芜湖市| 繁昌县| 安多县| 汉源县| 安义县| 晋宁县| 年辖:市辖区| 裕民县| 遂溪县| 井陉县| 万山特区| 高邑县| 翼城县| 龙川县| 什邡市| 汽车| 仙居县| 桂林市| 梧州市| 定襄县| 阿克苏市| 二手房| 株洲县| 呼伦贝尔市| 庆城县| 土默特右旗| 汉川市| 从江县| 浮山县|