-- 创建表
CREATE TABLE maintain_sum (
    id varchar(36) not null PRIMARY KEY,
    building_id varchar(50),
    cur_date varchar(50),
    day_num int,
    day_p varchar(50),
    week_num int,
    week_p varchar(50),
    month_num int,
    month_p varchar(50),
    year_num int,
    year_p varchar(50)
);

-- 添加表注释（可选，原脚本未提供表注释）
COMMENT ON TABLE maintain_sum IS '维护汇总表';

-- 添加列注释
COMMENT ON COLUMN maintain_sum.id IS '序号';
COMMENT ON COLUMN maintain_sum.building_id IS '楼栋编号';
COMMENT ON COLUMN maintain_sum.cur_date IS '日期';
COMMENT ON COLUMN maintain_sum.day_num IS '当日维修量';
COMMENT ON COLUMN maintain_sum.day_p IS '当日维修与昨日比';
COMMENT ON COLUMN maintain_sum.week_num IS '最近七天维修量';
COMMENT ON COLUMN maintain_sum.week_p IS '与上周比';
COMMENT ON COLUMN maintain_sum.month_num IS '月维修量';
COMMENT ON COLUMN maintain_sum.month_p IS '与上月比';
COMMENT ON COLUMN maintain_sum.year_num IS '年维修量';
COMMENT ON COLUMN maintain_sum.year_p IS '与上年比';

    -- 创建唯一约束
ALTER TABLE maintain_sum ADD CONSTRAINT uniq_maintain_sum
    UNIQUE (cur_date, building_id);
