批量生成修改oracle/sql server/mysql数据库各个表相同名字列的长度语句

--oracle
SELECT ‘alter table ‘ || TABLE_NAME ||‘ modify 列名 VARCHAR2(300);‘ FROM USER_TAB_COLUMNS WHERE COLUMN_NAME = ‘列名‘ and TABLE_NAME;
--sql server
SELECT ‘alter table ‘ + TABLE_NAME + ‘ alter column 列名 VARCHAR(300);‘ FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME =‘列名‘;
--mysql
select concat(‘alter table ‘,table_name,‘ modify column 列名 VARCHAR(300);‘) from information_schema.columns WHERE COLUMN_NAME = ‘列名‘;

相关推荐