创建测试表 create table tb_test_maxcolumn(c1 int); 查询当前测试表的字段名 select attname from pg_attribute,pg_class a where attrelid=a.oid and relname='tb_test_maxcolumn'; 查询当前测试表的字段数` select count(attname) from pg_attribute,pg_class a where attrelid=a.oid and relname='tb_test_maxcolumn'; 创建函数,函数实现增加字段使表字段达到1600个 create function addcolumn1600() returns varchar language 'plpgsql' as $$ declare v_idx integer:=2; v_column varchar(10); v_sql varchar(100); begin while v_idx < 1594 loop v_column := concat('c',v_idx); v_sql := 'alter table tb_test_maxcolumn add column '||v_column||' int'; v_idx := v_idx+1; execute v_sql; end loop; return 'SUCCESS'; end; $$; 调用函数,增加表字段 select addcolumn1600(); 查询当前表字段数 select count(attname) from pg_attribute,pg_class a where attrelid=a.oid and relname='tb_test_maxcolumn';