修改mysql資料庫字段內容預設值為當前時間

2022-03-17 06:47:05 字數 885 閱讀 9068

--新增createtime 設定預設時間 current_timestamp

alter tabletable_name

add columncreatetimedatetime null default current_timestamp comment '建立時間' ;

--修改createtime 設定預設時間 current_timestamp

alter tabletable_name

modify columncreatetimedatetime null default current_timestamp comment '建立時間' ;

--新增updatetime 設定 預設時間 current_timestamp 設定更新時間為 on update current_timestamp

alter tabletable_name

add columnupdatetimetimestamp null default current_timestamp on update current_timestamp comment '建立時間' ;

--修改 updatetime 設定 預設時間 current_timestamp 設定更新時間為 on update current_timestamp

alter tabletable_name

modify columnupdatetimetimestamp null default current_timestamp on update current_timestampcomment '建立時間' ;

批量修改資料庫某欄位內容

今天,遇到乙個問題 資料庫某欄位url記錄的為檔案存放的fpt位址,因為調整,ftp位址發生了變化,需要將資料庫中記錄的位址做相應的改動。原欄位url的內容類似於 ftp user 888 www.123.com 周杰倫 簡單愛.現在需要更改為 ftp user 666 www.456.com 周杰...

資料庫修改字段

一 更改字段型別長度 a mysql alter table 表名 change 原欄位名 新欄位名 字段型別 b oracle alter table 表名 rename column 原欄位名 to 新欄位名 二 更改字段型別 alter table 表名 alter column 欄位名 更改...

mysql資料庫修改欄位及新增字段指令碼

1.修改欄位的長度 alter table 表名 modify column 欄位名 資料型別 修改後的長度 例句 alter table test table modify column id int 20 2.修改欄位的名稱 alter table 表名 change 欄位名 欄位新名稱 欄位的...