修改字段长度
alter table 表名 alter column 字段名 type VARCHAR(1024);
ALTER TABLE 表名 alter COLUMN 字段名 type varchar(300);
将 ‘表名’ 的 ‘字段名’ 修改为300长度;
修改字段长度
alter table 表名 alter column 字段名 type VARCHAR(1024);
-- 新增字段
alter table xxx add column created_by varchar(42) DEFAULT null
alter table xxx add column created_date TIMESTAMP DEFAULT null
alter table xxx add column updated_by varchar(42) DEFAULT null
alter table xxx add column updated_date TIMESTAMP DEFAULT null
comment on column xxx.created_by is '创建人'
comment on column xxx.created_date is '创建时间'
comment on column xxx.updated_by is '修改人'
comment on column xxx.updated_date is '修改时间'
-- 修改字段长度
alter table 表名alter column 字段名type character varying(20);
-- 修改字段名称
ALTER TABLE 表名 RENAME 原字段名TO 新字段名;
select row_to_json(t.*) as line from pssf.path_data t
select key,value
from
(select row_to_json(t.*) as line from pssf.path_data t)a1 --1.先列转行
join LATERAL json_each_text(a1.line) on(key ~*'') --解析key ''里面代表正则表达式,表示匹配全部
select key as "字段名",max(length(value)) as "字段数据最大长度"
from
(select row_to_json(t.*) as line from pssf.path_data t)a1 --1.先列转行
join LATERAL json_each_text(a1.line) on(key ~*'') --解析key
group by key order by 字段数据最大长度 desc --2.然后按照字段名分组,求字段数据最大长度
此表MANAGEZONE字段中数据最大长度为990。