MySQL 修改int类型为bigint SQL语句拼接
Posted Hank.Yoon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL 修改int类型为bigint SQL语句拼接相关的知识,希望对你有一定的参考价值。
SELECT
CONCAT(
"alter table ",
TABLE_SCHEMA,
".",
TABLE_NAME,
" modify ",
COLUMN_NAME,
" bigint(20)",
IF
( IS_NULLABLE = ‘NO‘, " NOT NULL", "" ),
IF
( EXTRA = "", "", " AUTO_INCREMENT" ),
IF
( COLUMN_DEFAULT IS NULL, "", CONCAT( " DEFAULT ", COLUMN_DEFAULT ) ),
IF
( COLUMN_COMMENT = "", "", CONCAT( " COMMENT ‘", COLUMN_COMMENT, "‘" ) ),
";"
) AS alter_sql
FROM
information_schema.COLUMNS
WHERE
( COLUMN_NAME = ‘orderid‘ OR COLUMN_NAME = ‘order_id‘ )
AND DATA_TYPE = ‘int‘;
以上是关于MySQL 修改int类型为bigint SQL语句拼接的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 中的 CASE 强制列数据类型为 BIGINT 而不是 INT