自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL設(shè)置當(dāng)前時(shí)間為默認(rèn)值的方法

數(shù)據(jù)庫(kù) MySQL
在mysql創(chuàng)建表的時(shí)候經(jīng)常會(huì)遇到創(chuàng)建日期字段需要設(shè)置當(dāng)前時(shí)間為默認(rèn)值的問(wèn)題,下文就教您一個(gè)處理該問(wèn)題的放法,供您參考借鑒。

MySQL設(shè)置當(dāng)前時(shí)間為默認(rèn)值的問(wèn)題我們經(jīng)常會(huì)遇到,下面就為您介紹MySQL設(shè)置當(dāng)前時(shí)間為默認(rèn)值的實(shí)現(xiàn)全步驟,希望對(duì)您能有所啟迪。

數(shù)據(jù)庫(kù):test_db1

創(chuàng)建表:test_ta1

兩個(gè)字段:id              (自增 且為主鍵),

createtime 創(chuàng)建日期(默認(rèn)值為當(dāng)前時(shí)間)

方法一、是用alert table語(yǔ)句:

  1. use test_db1;  
  2.  
  3. create table test_ta1(  
  4.  
  5. id mediumint(8) unsigned not nulll auto_increment,  
  6.  
  7. createtime datetime,  
  8.  
  9. primary key (id)  
  10.  
  11. )engine=innodb default charset=gbk;  
  12.  
  13. alert table test_ta1 change createtime createtime timestamp not null default now();  
  14.  

方法二、直接創(chuàng)建方便:

  1. use test_db1;  
  2.  
  3. create table test_ta1(  
  4.  
  5. id mediumint(8) unsigned not nulll auto_increment,  
  6.  
  7. createtime timestamp not null default current_timestamp,  
  8.  
  9. primary key (id)  
  10.  
  11. )engine=innodb default charset=gbk;  
  12.  

方法三、可視化工具如 mysql-front

右擊createtime屬性

把Type屬性值改為timestamp

default 屬性選擇<INSERT-TimeStamp>

以上就是MySQL設(shè)置當(dāng)前時(shí)間為默認(rèn)值的方法介紹。

 

 

【編輯推薦】

MySQL分表處理的實(shí)現(xiàn)方法

MySQL授權(quán)表使用示例

MySQL多表刪除的實(shí)現(xiàn)

MySQL獨(dú)立表空間的優(yōu)缺點(diǎn)

mysql數(shù)據(jù)庫(kù)大小寫的問(wèn)題討論

責(zé)任編輯:段燃 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2021-02-25 13:40:17

MySQL數(shù)據(jù)庫(kù)默認(rèn)值

2022-06-21 08:13:34

MySQL查詢數(shù)據(jù)庫(kù)

2011-08-23 18:46:27

MySQLTIMESTAMP

2011-08-23 18:30:59

MySQLTIMESTAMP

2010-10-22 16:56:35

sql server刪

2009-12-18 17:07:14

2010-10-22 15:36:57

2010-09-28 10:23:36

SQL修改字段

2009-09-11 12:31:15

C# WinForm控設(shè)置默認(rèn)值

2012-08-01 09:50:11

交互設(shè)計(jì)UI設(shè)計(jì)

2010-07-15 10:37:15

SQL Server默

2009-12-24 16:03:16

ADO.NET部署

2010-09-28 10:35:58

SQL字段默認(rèn)值

2018-04-12 13:41:14

Windows 10Windows文件關(guān)聯(lián)重置

2010-09-28 15:24:43

sql語(yǔ)句

2010-09-07 16:05:23

SQL語(yǔ)句刪除

2010-10-11 16:35:54

MySql時(shí)間函數(shù)

2010-09-03 10:52:10

SQL刪除

2018-04-13 14:32:02

Windows10文件關(guān)聯(lián)默認(rèn)值

2010-09-16 10:56:46

sqlserver建表
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)