# complaint_details_fix_ywd_day

## 插入语句

```sql
INSERT INTO tsl_data.complaint_details_fix_ywd_day
(id, month_id, day_id, month_id1, day_id1, sheet_no, is_online_complete, contact_no, busi_no, serv_content, last_deal_content, deal_depart_name, deal_user, deal_opinion, complete_user_code, serv_type, bus_type, duty_reason, problem_duty, problem_solving_con, code_urgent_level, code_important_type, cust_name, accept_user, cust_level, accept_channel, submit_channel, compl_area_local, compl_city_local, compl_grid_local, cust_province, accept_time, end_time, cust_area, duty_major, is_call_center_complete, is_cust_serv_complete, is_send_sheet_complete, sp_code, sp_name, is_repeat, is_timeout, duty_dept, proce_user_code, proce_time, proce_depart_name, proce_remark, satisfaction, is_ok, is_ok_in_reply, product_name, pre_repair_name, pre_repair_charges, actual_total_len, timeout_len, timeout_depart_name, sp_product_code, sp_product_name, process_nums, deal_depart_name_1, deal_user_1, sended_user_1, deal_depart_name_2, deal_user_2, sended_user_2, deal_depart_name_3, deal_user_3, sended_user_3, deal_depart_name_end, deal_user_end, sended_depart_name_last, first_call_back_time, duty_reason_id_day, duty_major_day, duty_reason_id_month, duty_major_month, voice_text, fault_location, satisfaction_in_reply, is_upgrade, gis_city, data_source, code_answer_way, success_call_back, last_satisfaction, last_is_ok, design_profess, deal_unit, province_deal_unit, if_direct, is_proself, timely_contact, is_repeat_5times_m, is_repeat_2times_m, is_repeat_2times_2m, is_repeat_2times_3m, create_time)
VALUES(0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', now());
```

## 建表语句

- 一个语句完成

```sql
CREATE TABLE tsl_data.complaint_details_fix_ywd_day (
  id bigserial NOT NULL,
  month_id character varying(6),
  day_id character varying(6),
  month_id1 character varying(18),
  day_id1 character varying(6),
  sheet_no character varying(150),
  is_online_complete character varying(6),
  contact_no character varying(150),
  busi_no character varying(150),
  serv_content character varying(4136),
  last_deal_content character varying(4136),
  deal_depart_name character varying(300),
  deal_user character varying(60),
  deal_opinion character varying(4136),
  complete_user_code character varying(150),
  serv_type character varying(600),
  bus_type character varying(30),
  duty_reason character varying(600),
  problem_duty character varying(300),
  problem_solving_con character varying(300),
  code_urgent_level character varying(300),
  code_important_type character varying(300),
  cust_name character varying(300),
  accept_user character varying(600),
  cust_level character varying(300),
  accept_channel character varying(300),
  submit_channel character varying(300),
  compl_area_local character varying(300),
  compl_city_local character varying(90),
  compl_grid_local character varying(210),
  cust_province character varying(300),
  accept_time character varying(300),
  end_time character varying(300),
  cust_area character varying(300),
  duty_major character varying(300),
  is_call_center_complete character varying(6),
  is_cust_serv_complete character varying(6),
  is_send_sheet_complete character varying(6),
  sp_code character varying(600),
  sp_name character varying(600),
  is_repeat character varying(50),
  is_timeout character varying(50),
  duty_dept character varying(300),
  proce_user_code character varying(60),
  proce_time character varying(300),
  proce_depart_name character varying(1500),
  proce_remark character varying(4136),
  satisfaction character varying(50),
  is_ok character varying(50),
  is_ok_in_reply character varying(300),
  product_name character varying(600),
  pre_repair_name character varying(60),
  pre_repair_charges character varying(60),
  actual_total_len character varying(60),
  timeout_len character varying(60),
  timeout_depart_name character varying(300),
  sp_product_code character varying(600),
  sp_product_name character varying(600),
  process_nums character varying(60),
  deal_depart_name_1 character varying(300),
  deal_user_1 character varying(150),
  sended_user_1 character varying(150),
  deal_depart_name_2 character varying(300),
  deal_user_2 character varying(150),
  sended_user_2 character varying(150),
  deal_depart_name_3 character varying(300),
  deal_user_3 character varying(150),
  sended_user_3 character varying(150),
  deal_depart_name_end character varying(300),
  deal_user_end character varying(60),
  sended_depart_name_last character varying(300),
  first_call_back_time character varying(60),
  duty_reason_id_day character varying(300),
  duty_major_day character varying(50),
  duty_reason_id_month character varying(300),
  duty_major_month character varying(50),
  voice_text character varying(4136),
  fault_location character varying(500),
  satisfaction_in_reply character varying(300),
  is_upgrade character varying(6),
  gis_city character varying(210),
  data_source character varying(60),
  code_answer_way character varying(15),
  success_call_back character varying(50),
  last_satisfaction character varying(50),
  last_is_ok character varying(50),
  design_profess character varying(300),
  deal_unit character varying(150),
  province_deal_unit character varying(150),
  if_direct character varying(50),
  is_proself character varying(50),
  timely_contact character varying(50),
  is_repeat_5times_m character varying(50),
  is_repeat_2times_m character varying(50),
  is_repeat_2times_2m character varying(50),
  is_repeat_2times_3m character varying(50),
  create_time timestamp without time zone DEFAULT now(),
  CONSTRAINT complaint_details_fix_ywd_day_pkey PRIMARY KEY (id)
)
```

- 分步建表

```sql
CREATE TABLE tsl_data.complaint_details_fix_ywd_day (
  id bigint NOT NULL,
  month_id character varying(6),
  day_id character varying(6),
  month_id1 character varying(18),
  day_id1 character varying(6),
  sheet_no character varying(150),
  is_online_complete character varying(6),
  contact_no character varying(150),
  busi_no character varying(150),
  serv_content character varying(4136),
  last_deal_content character varying(4136),
  deal_depart_name character varying(300),
  deal_user character varying(60),
  deal_opinion character varying(4136),
  complete_user_code character varying(150),
  serv_type character varying(600),
  bus_type character varying(30),
  duty_reason character varying(600),
  problem_duty character varying(300),
  problem_solving_con character varying(300),
  code_urgent_level character varying(300),
  code_important_type character varying(300),
  cust_name character varying(300),
  accept_user character varying(600),
  cust_level character varying(300),
  accept_channel character varying(300),
  submit_channel character varying(300),
  compl_area_local character varying(300),
  compl_city_local character varying(90),
  compl_grid_local character varying(210),
  cust_province character varying(300),
  accept_time character varying(300),
  end_time character varying(300),
  cust_area character varying(300),
  duty_major character varying(300),
  is_call_center_complete character varying(6),
  is_cust_serv_complete character varying(6),
  is_send_sheet_complete character varying(6),
  sp_code character varying(600),
  sp_name character varying(600),
  is_repeat character varying(50),
  is_timeout character varying(50),
  duty_dept character varying(300),
  proce_user_code character varying(60),
  proce_time character varying(300),
  proce_depart_name character varying(1500),
  proce_remark character varying(4136),
  satisfaction character varying(50),
  is_ok character varying(50),
  is_ok_in_reply character varying(300),
  product_name character varying(600),
  pre_repair_name character varying(60),
  pre_repair_charges character varying(60),
  actual_total_len character varying(60),
  timeout_len character varying(60),
  timeout_depart_name character varying(300),
  sp_product_code character varying(600),
  sp_product_name character varying(600),
  process_nums character varying(60),
  deal_depart_name_1 character varying(300),
  deal_user_1 character varying(150),
  sended_user_1 character varying(150),
  deal_depart_name_2 character varying(300),
  deal_user_2 character varying(150),
  sended_user_2 character varying(150),
  deal_depart_name_3 character varying(300),
  deal_user_3 character varying(150),
  sended_user_3 character varying(150),
  deal_depart_name_end character varying(300),
  deal_user_end character varying(60),
  sended_depart_name_last character varying(300),
  first_call_back_time character varying(60),
  duty_reason_id_day character varying(300),
  duty_major_day character varying(50),
  duty_reason_id_month character varying(300),
  duty_major_month character varying(50),
  voice_text character varying(4136),
  fault_location character varying(500),
  satisfaction_in_reply character varying(300),
  is_upgrade character varying(6),
  gis_city character varying(210),
  data_source character varying(60),
  code_answer_way character varying(15),
  success_call_back character varying(50),
  last_satisfaction character varying(50),
  last_is_ok character varying(50),
  design_profess character varying(300),
  deal_unit character varying(150),
  province_deal_unit character varying(150),
  if_direct character varying(50),
  is_proself character varying(50),
  timely_contact character varying(50),
  is_repeat_5times_m character varying(50),
  is_repeat_2times_m character varying(50),
  is_repeat_2times_2m character varying(50),
  is_repeat_2times_3m character varying(50),
  create_time timestamp without time zone DEFAULT now()
)

-- 创建seq
CREATE SEQUENCE tsl_data.complaint_details_fix_ywd_day_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 将seq指配给id字段
ALTER SEQUENCE tsl_data.complaint_details_fix_ywd_day_id_seq OWNED BY tsl_data.complaint_details_fix_ywd_day.id;

-- id 的default值
ALTER TABLE ONLY tsl_data.complaint_details_fix_ywd_day ALTER COLUMN id SET DEFAULT nextval('tsl_data.complaint_details_fix_ywd_day_id_seq'::regclass);

-- 将id作为主键
ALTER TABLE ONLY tsl_data.complaint_details_fix_ywd_day
    ADD CONSTRAINT complaint_details_fix_ywd_day_pkey PRIMARY KEY (id);
```
