简体   繁体   中英

ALTER data type for all tables in db MySQL

I want to convert all DATETIME columns in my db to DATETIME(6). Is there one command that I can I use to do this? I have a lot of tables and curious if there is a quick method.

Something that would do this logic

FOR T IN TABLES ALTER TABLE T MODIFY ALL DATETIME TO DATETIME(6)

if u are using my sql server, u can use an undocumented stored procedure to do this

EXEC ms_foreachtable 'ALTER TABLE [?] .....'

Replace table name with ? in statement

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM