0300_ddl_gradata_tables.sql 32.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
prompt Creating gradata.GRAS_BRANCH_ASSIGN_RULE...
create table gradata.GRAS_BRANCH_ASSIGN_RULE
(
  branch_code  VARCHAR2(10) not null,
  assign_rule  VARCHAR2(2) not null,
  priority     NUMBER(2) not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BRANCH_ASSIGN_RULE
  is '机构分单规则信息表';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.branch_code
  is '机构';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.assign_rule
  is '分单规则';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.priority
  is '优先级';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.created_user
  is '录入人';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.created_date
  is '录入日期';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.updated_user
  is '修改人';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.updated_date
  is '修改日期';
comment on column gradata.GRAS_BRANCH_ASSIGN_RULE.pk_serial
  is '数据主键';
alter table gradata.GRAS_BRANCH_ASSIGN_RULE
  add constraint PK_GRAS_BRANCH_ASSIGN_RULE primary key (BRANCH_CODE,PRIORITY);
alter table gradata.GRAS_BRANCH_ASSIGN_RULE
  add constraint FK_GRAS_BRAN_ASS_RUL_BRA_CODE foreign key (BRANCH_CODE)
  references SLISINTF.BRANCH_INFO(BRANCH_CODE);
alter table gradata.GRAS_BRANCH_ASSIGN_RULE
  add constraint FK_GRAS_BRAN_ASS_RUL_ASS_RUL foreign key (ASSIGN_RULE)
  references GRARULE.GRAS_ASSIGN_RULE(ASSIGN_RULE);

prompt Creating gradata.GRAS_AREA_STAFF...
create table gradata.GRAS_AREA_STAFF
(
  area_no      VARCHAR2(10) not null,
  channel_type VARCHAR2(2) not null,
  is_valid     VARCHAR2(1) default 'Y' not null,
  servicer_no  VARCHAR2(20) not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_AREA_STAFF
  is '区域人员匹配表';
comment on column gradata.GRAS_AREA_STAFF.area_no
  is '区域代码';
comment on column gradata.GRAS_AREA_STAFF.channel_type
  is '渠道';
comment on column gradata.GRAS_AREA_STAFF.is_valid
  is '是否有效';
comment on column gradata.GRAS_AREA_STAFF.pk_serial
  is '数据主键';
comment on column gradata.GRAS_AREA_STAFF.servicer_no
  is '区域服务人员代码';
comment on column gradata.GRAS_AREA_STAFF.created_user
  is '录入人 ';
comment on column gradata.GRAS_AREA_STAFF.created_date
  is '录入日期';
comment on column gradata.GRAS_AREA_STAFF.updated_user
  is '修改人';
comment on column gradata.GRAS_AREA_STAFF.updated_date
  is '修改日期';
alter table gradata.GRAS_AREA_STAFF
  add constraint PK_GRAS_AREA_STAFF primary key (PK_SERIAL);
alter table gradata.GRAS_AREA_STAFF
  add constraint FK_GRAS_AREA_STA_CHA_TYPE foreign key (CHANNEL_TYPE)
  references SLISINTF.CHANNEL_TYPE_TBL(CHANNEL_TYPE);
alter table gradata.GRAS_AREA_STAFF
  add constraint FK_GRAS_AREA_STA_EMP_NO foreign key (SERVICER_NO)
  references SLISINTF.STAFF_INFO(SERVICER_NO);
alter table gradata.GRAS_AREA_STAFF
  add constraint CK_GRAS_AREA_STAFF_IS_VALID
  check IS_VALID in ('Y','N');

create table gradata.GRAS_POLICY_GEO
(
  policy_no    VARCHAR2(20) not null,
  lon          NUMBER(10,6) default 0.0 not null,
  lat          NUMBER(10,6) default 0.0 not null,
  is_valid     VARCHAR2(1) default 'Y' not null,
  pk_serial    VARCHAR2(10),
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_POLICY_GEO
  is '保单地址匹配表';
comment on column gradata.GRAS_POLICY_GEO.policy_no
  is '保单号';
comment on column gradata.GRAS_POLICY_GEO.lon
  is '经度(墨卡托)';
comment on column gradata.GRAS_POLICY_GEO.lat
  is '纬度(墨卡托)';
comment on column gradata.GRAS_POLICY_GEO.created_user
  is '录入人 ';
comment on column gradata.GRAS_POLICY_GEO.created_date
  is '录入日期';
comment on column gradata.GRAS_POLICY_GEO.updated_user
  is '修改人';
comment on column gradata.GRAS_POLICY_GEO.updated_date
  is '修改日期';
comment on column gradata.GRAS_POLICY_GEO.is_valid
  is '是否有效';
comment on column gradata.GRAS_POLICY_GEO.pk_serial
  is '数据主键';
alter table gradata.GRAS_POLICY_GEO
  add constraint PK_GRAS_POLICY_GEO primary key (PK_SERIAL);
alter table gradata.GRAS_POLICY_GEO
  add constraint FK_GRAS_POLICY_GEO_POL_NO foreign key (POLICY_NO)
  references SLISINTF.POLICY(POLICY_NO);
alter table gradata.GRAS_POLICY_GEO
  add constraint CK_GRAS_POLICY_GEO_IS_VALID
  check IS_VALID in ('Y','N');
create index IX_GRAS_POLICY_GEO_1 on gradata.GRAS_POLICY_GEO (POLICY_NO);

create table gradata.GRAS_BRANCH_GEO
(
  branch_code  VARCHAR2(10) not null,
  layer_code   VARCHAR2(10) not null,
  layer_name   VARCHAR2(50) not null,
  paas_serial  VARCHAR2(50) not null,
  lon          NUMBER(10,6) not null,
  lat          NUMBER(10,6) not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BRANCH_GEO
  is '机构地址匹配表';
comment on column gradata.GRAS_BRANCH_GEO.branch_code
  is '机构代码';
comment on column gradata.GRAS_BRANCH_GEO.layer_code
  is '区块编号';
comment on column gradata.GRAS_BRANCH_GEO.layer_name
  is '区块名称';
comment on column gradata.GRAS_BRANCH_GEO.paas_serial
  is 'PAAS序列';
comment on column gradata.GRAS_BRANCH_GEO.created_user
  is '录入人 ';
comment on column gradata.GRAS_BRANCH_GEO.created_date
  is '录入日期';
comment on column gradata.GRAS_BRANCH_GEO.updated_user
  is '修改人 ';
comment on column gradata.GRAS_BRANCH_GEO.updated_date
  is '修改日期';
comment on column gradata.GRAS_BRANCH_GEO.lon
  is '经度';
comment on column gradata.GRAS_BRANCH_GEO.lat
  is '纬度';
alter table gradata.GRAS_BRANCH_GEO
  add constraint PK_GRAS_BRANCH_GEO primary key (PK_SERIAL);
alter table gradata.GRAS_BRANCH_GEO
  add constraint FK_GRAS_BRANCH_GEO_BRA_CODE foreign key (BRANCH_CODE)
  references SLISINTF.BRANCH_INFO(BRANCH_CODE);
create index IX_GRAS_BRANCH_GEO_1 on gradata.GRAS_BRANCH_GEO (BRANCH_CODE);
create index IX_GRAS_BRANCH_GEO_2 on gradata.GRAS_BRANCH_GEO (LAYER_CODE);

create table gradata.GRAS_BANK_GEO
(
  bank_code    VARCHAR2(12) not null,
  lon          NUMBER(10,6) not null,
  lat          NUMBER(10,6) not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BANK_GEO
  is '银行地址匹配表';
comment on column gradata.GRAS_BANK_GEO.bank_code
  is '银行代码';
comment on column gradata.GRAS_BANK_GEO.lon
  is '经度(墨卡托)';
comment on column gradata.GRAS_BANK_GEO.lat
  is '纬度(墨卡托)';
comment on column gradata.GRAS_BANK_GEO.created_user
  is '录入人 ';
comment on column gradata.GRAS_BANK_GEO.created_date
  is '录入日期';
comment on column gradata.GRAS_BANK_GEO.updated_user
  is '修改人';
comment on column gradata.GRAS_BANK_GEO.updated_date
  is '修改日期';
comment on column gradata.GRAS_BANK_GEO.pk_serial
  is '数据主键';
alter table gradata.GRAS_BANK_GEO
  add constraint PK_GRAS_BANK_GEO primary key (PK_SERIAL);
alter table gradata.GRAS_BANK_GEO
  add constraint FK_GRAS_BANK_GEO_BANK_CODE foreign key (BANK_CODE)
  references SLISINTF.BANK_INFO(BANK_CODE);
create index IX_GRAS_BANK_GEO_1 on gradata.GRAS_BANK_GEO (BANK_CODE);

create table gradata.GRAS_BANK_EMP
(
  bank_code    VARCHAR2(12) not null,
  emp_no       VARCHAR2(20) not null,
  begin_date   DATE not null,
  end_date     DATE,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BANK_EMP
  is '银行与续收人员关系表';
comment on column gradata.GRAS_BANK_EMP.bank_code
  is '银行代码';
comment on column gradata.GRAS_BANK_EMP.emp_no
  is '员工代码';
comment on column gradata.GRAS_BANK_EMP.begin_date
  is '指定起始日期';
comment on column gradata.GRAS_BANK_EMP.end_date
  is '指定终止日期';
comment on column gradata.GRAS_BANK_EMP.pk_serial
  is '数据主键';
comment on column gradata.GRAS_BANK_EMP.created_date
  is '录入日期';
comment on column gradata.GRAS_BANK_EMP.updated_user
  is '修改人  ';
comment on column gradata.GRAS_BANK_EMP.updated_date
  is '修改日期';
comment on column gradata.GRAS_BANK_EMP.created_user
  is '录入人 ';
alter table gradata.GRAS_BANK_EMP
  add constraint PK_gradata.GRAS_BANK_EMP primary key (BANK_CODE,EMP_NO,BEGIN_DATE);
alter table gradata.GRAS_BANK_EMP
  add constraint FK_gradata.GRAS_BANK_EMP_BAN_COD foreign key (BANK_CODE)
  references SLISINTF.BANK_INFO(BANK_CODE);
alter table gradata.GRAS_DEPT_SERVICER
  add constraint FK_GRAS_BANK_EMP_EMP_NO foreign key (EMP_NO)
  references SLISINTF.STAFF_INFO(EMP_NO);

create table gradata.GRAS_BRANCH_STYLE
(
  branch_code  VARCHAR2(10) not null,
  style_code   VARCHAR2(10) not null,
  remark       VARCHAR2(100) ,
  flag         VARCHAR2(1) default '0' not null,
  pk_serial    VARCHAR2(10) not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BRANCH_STYLE
  is '机构参数样式表';
comment on column gradata.GRAS_BRANCH_STYLE.flag
  is '变更标示:1-已变更,0-未变更';
comment on column gradata.GRAS_BRANCH_STYLE.style_code
  is '展示样式属性名';
comment on column gradata.GRAS_BRANCH_STYLE.remark
  is '描述说明';
comment on column gradata.GRAS_BRANCH_STYLE.branch_code
  is '机构代码';
comment on column gradata.GRAS_BRANCH_STYLE.updated_user
  is '修改人  ';
comment on column gradata.GRAS_BRANCH_STYLE.updated_date
  is '修改日期';
alter table gradata.GRAS_BRANCH_STYLE
  add constraint PK_GRAS_BRANCH_STYLE primary key (PK_SERIAL);
alter table gradata.GRAS_BRANCH_STYLE
  add constraint FK_GRAS_BRA_STY_BRA_COD foreign key (BRANCH_CODE)
  references SLISINTF.BRANCH_INFO(BRANCH_CODE);
alter table gradata.GRAS_BRANCH_STYLE
  add constraint FK_GRAS_BRA_STY_BRA_COD foreign key (STYLE_CODE)
  references GRARULE.GRAS_DISPLAY_STYLE(STYLE_CODE);
alter table gradata.GRAS_BRANCH_STYLE
  add constraint CK_GRAS_BRANCH_STYLE_FLAG
  check (FLAG in ('1','0'));

create table gradata.GRAS_ASSIGN_RULE_CHGS
(
  policy_no           VARCHAR2(20) not null,
  branch_code         VARCHAR2(10) not null,
  last_assign_type    VARCHAR2(2),
  next_assign_type    VARCHAR2(2),
  last_assign_value   VARCHAR2(10),
  next_assign_value   VARCHAR2(10),
  change_user         VARCHAR2(50) not null,
  change_date         DATE default SYSDATE not null,
  pk_serial           VARCHAR2(10) not null,
  created_user        VARCHAR2(100) not null,
  created_date        DATE default SYSDATE not null,
  updated_user        VARCHAR2(100) not null,
  updated_date        DATE default SYSDATE not null
);
comment on table gradata.GRAS_ASSIGN_RULE_CHGS
  is '保单分单规则调整记录表';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.policy_no
  is '保单号';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.branch_code
  is '机构代码';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.next_assign_type
  is '调整后分单类型';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.next_assign_value
  is '调整后值';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.change_user
  is '调整人员';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.change_date
  is '调整日期';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.pk_serial
  is '数字主键';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.created_user
  is '录入人';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.created_date
  is '录入日期';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.updated_user
  is '修改人';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.updated_date
  is '修改日期';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.last_assign_type
  is '调整前后分单类型';
comment on column gradata.GRAS_ASSIGN_RULE_CHGS.last_assign_value
  is '调整前值';
alter table gradata.GRAS_ASSIGN_RULE_CHGS
  add constraint PK_GRAS_ASSIGN_RULE_CHGS primary key (PK_SERIAL);
alter table gradata.GRAS_ASSIGN_RULE_CHGS
  add constraint FK_GRAS_ASS_RUL_CH_POL_NO foreign key (POLICY_NO)
  references SLISINTF.POLICY(POLICY_NO);
alter table gradata.GRAS_ASSIGN_RULE_CHGS
  add constraint FK_GRAS_ASS_RUL_CH_LA_ASS_TY foreign key (LAST_ASSIGN_TYPE)
  references GRARULE.GRAS_ASSIGN_TYPE(ASSIGN_TYPE);
alter table gradata.GRAS_ASSIGN_RULE_CHGS
  add constraint FK_GRAS_ASS_RUL_CH_NE_ASS_TY foreign key (NEXT_ASSIGN_TYPE)
  references GRARULE.GRAS_ASSIGN_TYPE(ASSIGN_TYPE);

create table gradata.GRAS_DEPT_SERVICER
(
  dept_no      VARCHAR2(20) not null,
  servicer_no  VARCHAR2(20) not null,
  is_valid     VARCHAR2(1) default 'Y' not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_DEPT_SERVICER
  is '部门对应服务人员设置';
comment on column gradata.GRAS_DEPT_SERVICER.dept_no
  is '部门代码';
comment on column gradata.GRAS_DEPT_SERVICER.servicer_no
  is '服务人员代码';
comment on column gradata.GRAS_DEPT_SERVICER.is_valid
  is '是否有效';
comment on column gradata.GRAS_DEPT_SERVICER.created_user
  is '录入人';
comment on column gradata.GRAS_DEPT_SERVICER.updated_user
  is '修改人';
comment on column gradata.GRAS_DEPT_SERVICER.created_date
  is '录入时间';
comment on column gradata.GRAS_DEPT_SERVICER.updated_date
  is '修改日期';
comment on column gradata.GRAS_DEPT_SERVICER.pk_serial
  is '数据主键';
alter table gradata.GRAS_DEPT_SERVICER
  add constraint PK_GRAS_DEPT_SERVICER primary key (PK_SERIAL);
alter table gradata.GRAS_DEPT_SERVICER
  add constraint FK_GRAS_DEPT_SERV_DEPT_NO foreign key (DEPT_NO)
  references SLISINTF.DEPARTMENT_INFO(DEPT_NO);
alter table gradata.GRAS_DEPT_SERVICER
  add constraint FK_GRAS_DEPT_SERV_SERV_NO foreign key (SERVICER_NO)
  references SLISINTF.STAFF_INFO(EMP_NO);
alter table gradata.GRAS_DEPT_SERVICER
  add constraint CK_GRAS_DEPT_SERV_IS_VAL
  check (IS_VALID in ('Y','N'));

create table gradata.GRAS_BRANCH_SERVICER
(
  branch_code  VARCHAR2(10) not null,
  servicer_no  VARCHAR2(20),
  is_valid     VARCHAR2(1) default 'Y' not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_BRANCH_SERVICER
  is '营销服务部对应服务人员设置';
comment on column gradata.GRAS_BRANCH_SERVICER.branch_code
  is '机构代码';
comment on column gradata.GRAS_BRANCH_SERVICER.servicer_no
  is '服务人员代码';
comment on column gradata.GRAS_BRANCH_SERVICER.is_valid
  is '是否有效';
comment on column gradata.GRAS_BRANCH_SERVICER.created_user
  is '录入人';
comment on column gradata.GRAS_BRANCH_SERVICER.created_date
  is '录入日期';
comment on column gradata.GRAS_BRANCH_SERVICER.updated_user
  is '修改人';
comment on column gradata.GRAS_BRANCH_SERVICER.updated_date
  is '修改日期';
comment on column gradata.GRAS_BRANCH_SERVICER.pk_serial
  is '数据主键';
alter table gradata.GRAS_BRANCH_SERVICER
  add constraint PK_GRAS_BRANCH_SERVICER primary key (PK_SERIAL);
alter table gradata.GRAS_BRANCH_SERVICER
  add constraint FK_GRAS_BRANCH_SERV_BRA_CO foreign key (BRANCH_CODE)
  references SLISINTF.BRANCH_INFO(BRANCH_CODE);
alter table gradata.GRAS_BRANCH_SERVICER
  add constraint FK_GRAS_BRANCH_SERV_DEPT_NO foreign key (EMP_NO)
  references SLISINTF.STAFF_INFO(EMP_NO);
alter table gradata.GRAS_BRANCH_SERVICER
  add constraint CK_GRAS_BRANCH_SERV_IS_VAL
  check (IS_VALID in ('Y','N'));

create table gradata.GRAS_POLICY_SERVICER_ASSIGN
(
  policy_no           VARCHAR2(20) not null,
  assign_service_type VARCHAR2(2) not null,
  servicer_no         VARCHAR2(20),
  begin_date          DATE not null,
  end_date            DATE,
  pk_serial           VARCHAR2(10) not null,
  created_user        VARCHAR2(100) not null,
  created_date        DATE default SYSDATE not null,
  updated_user        VARCHAR2(100) not null,
  updated_date        DATE default SYSDATE not null
);
comment on table gradata.GRAS_POLICY_SERVICER_ASSIGN
  is '保单服务人员指定表';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.policy_no
  is '保单号';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.assign_service_type
  is '指定服务类型';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.servicer_no
  is '指定服务人员';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.begin_date
  is '指定起始日期';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.end_date
  is '指定终止日期';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.pk_serial
  is '数字主键';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.created_user
  is '录入人 ';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.created_date
  is '录入日期';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.updated_user
  is '修改人';
comment on column gradata.GRAS_POLICY_SERVICER_ASSIGN.updated_date
  is '修改日期';
alter table gradata.GRAS_POLICY_SERVICER_ASSIGN
  add constraint PK_GRAS_POLICY_SERVICER_ASSIGN primary key (POLICY_NO,ASSIGN_SERVICE_TYPE,BEGIN_DATE);
alter table gradata.GRAS_POLICY_SERVICER_ASSIGN
  add constraint FK_GRAS_POL_SERV_ASS_SERV_TY foreign key (ASSIGN_SERVICE_TYPE)
  references GRARULE.GRAS_ASSIGN_SERVICE(ASSIGN_SERVICE_TYPE);
alter table gradata.GRAS_POLICY_SERVICER_ASSIGN
  add constraint FK_GRAS_POL_SERV_ASS_SERV_NO foreign key (SERVICER_NO)
  references SLISINTF.STAFF_INFO(SERVICER_NO);

create table gradata.GRAS_SYS_ROLE
(
  role_id      VARCHAR2(30) not null,
  role_name    VARCHAR2(50),
  description  VARCHAR2(100),
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_SYS_ROLE
  is '角色表';
comment on column gradata.GRAS_SYS_ROLE.role_id
  is '角色ID';
comment on column gradata.GRAS_SYS_ROLE.role_name
  is '角色名称';
comment on column gradata.GRAS_SYS_ROLE.description
  is '备注';
comment on column gradata.GRAS_SYS_ROLE.pk_serial
  is '数字主键';
comment on column gradata.GRAS_SYS_ROLE.created_user
  is '录入人 ';
comment on column gradata.GRAS_SYS_ROLE.created_date
  is '录入日期';
comment on column gradata.GRAS_SYS_ROLE.updated_user
  is '修改人';
comment on column gradata.GRAS_SYS_ROLE.updated_date
  is '修改日期';
alter table gradata.GRAS_SYS_ROLE
  add constraint PK_GRAS_SYS_ROLE primary key (ROLE_ID);

create table gradata.GRAS_SYS_MENU
(
  menu_id        VARCHAR2(4) not null,
  menu_name      VARCHAR2(50) not null,
  menu_id_father VARCHAR2(4),
  menu_url       VARCHAR2(100) not null,
  pk_serial      VARCHAR2(10) not null,
  created_user   VARCHAR2(100) not null,
  created_date   DATE default SYSDATE not null,
  updated_user   VARCHAR2(100) not null,
  updated_date   DATE default SYSDATE not null
);
comment on table GRAS_SYS_MENU
  is '菜单表';
comment on column GRAS_SYS_MENU.menu_name
  is '权限名称';
comment on column GRAS_SYS_MENU.menu_id_father
  is '权限父ID';
comment on column GRAS_SYS_MENU.menu_url
  is '菜单路径,对应页面的菜单项';
comment on column GRAS_SYS_MENU.menu_id
  is '菜单id';
comment on column GRAS_SYS_MENU.pk_serial
  is '数字主键';
comment on column GRAS_SYS_MENU.created_user
  is '录入人 ';
comment on column GRAS_SYS_MENU.created_date
  is '录入日期';
comment on column GRAS_SYS_MENU.updated_user
  is '修改人';
comment on column GRAS_SYS_MENU.updated_date
  is '修改日期';
alter table gradata.GRAS_SYS_MENU
  add constraint PK_GRAS_SYS_MENU primary key (MENU_ID);

create table gradata.GRAS_SYS_ROLE_MENU
(
  role_id      VARCHAR2(30) not null,
  menu_id      VARCHAR2(4) not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_SYS_ROLE_MENU
  is '角色与菜单关系表';
comment on column gradata.GRAS_SYS_ROLE_MENU.role_id
  is '角色ID';
comment on column gradata.GRAS_SYS_ROLE_MENU.menu_id
  is '权限ID';
comment on column gradata.GRAS_SYS_ROLE.pk_serial
  is '数字主键';
comment on column gradata.GRAS_SYS_ROLE_MENU.created_user
  is '录入人 ';
comment on column gradata.GRAS_SYS_ROLE_MENU.created_date
  is '录入日期';
comment on column gradata.GRAS_SYS_ROLE_MENU.updated_user
  is '修改人';
comment on column gradata.GRAS_SYS_ROLE_MENU.updated_date
  is '修改日期';
alter table gradata.GRAS_SYS_ROLE_MENU
  add constraint PK_GRAS_SYS_ROLE_MENU primary key (PK_SERIAL);
alter table gradata.GRAS_SYS_ROLE_MENU
  add constraint FK_GRAS_SYS_RO_ME_RO_ID foreign key (ROLE_ID)
  references GRADATA.GRAS_SYS_ROLE(ROLE_ID);
alter table gradata.GRAS_SYS_ROLE_MENU
  add constraint FK_GRAS_SYS_RO_ME_ME_ID foreign key (MENU_ID)
  references GRADATA.GRAS_SYS_MENU(MENU_ID);

create table gradata.GRAS_SYS_DATA_TRANS
(
  target_table VARCHAR2(50) not null,
  target_id    VARCHAR2(10) not null,
  orcl_flag    VARCHAR2(1) default 'Y' not null,
  es_flag      VARCHAR2(1) default 'Y' not null,
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);
comment on table gradata.GRAS_SYS_DATA_TRANS
  is '数据传输记录';
comment on column gradata.GRAS_SYS_DATA_TRANS.target_table
  is '数据所在表名';
comment on column gradata.GRAS_SYS_DATA_TRANS.target_id
  is '数据对应的ID';
comment on column gradata.GRAS_SYS_DATA_TRANS.orcl_flag
  is 'ORACLE数据库传输正常标示,指示接口传输是否正常';
comment on column gradata.GRAS_SYS_DATA_TRANS.es_flag
  is 'ES数据库传输正常标示,
指示数据同步是否正常';
comment on column gradata.GRAS_SYS_DATA_TRANS.pk_serial
  is '数字主键';
comment on column gradata.GRAS_SYS_DATA_TRANS.created_user
  is '录入人 ';
comment on column gradata.GRAS_SYS_DATA_TRANS.created_date
  is '录入日期';
comment on column gradata.GRAS_SYS_DATA_TRANS.updated_user
  is '修改人';
comment on column gradata.GRAS_SYS_DATA_TRANS.updated_date
  is '修改日期';
alter table gradata.GRAS_SYS_DATA_TRANS
  add constraint PK_GRAS_SYS_DATA_TRANS primary key (PK_SERIAL);
alter table gradata.GRAS_SYS_DATA_TRANS
  add constraint CK_GRAS_SYS_DATA_TRANS_ORCL
  check (ORCL_FLAG in ('Y','N'));
alter table gradata.GRAS_SYS_DATA_TRANS
  add constraint CK_GRAS_SYS_DATA_TRANS_ES
  check (ES_FLAG in ('Y','N'));
  
  
create table gradata.GRAS_BATCH_PLAN
(
  sequence             VARCHAR2(10) not null,
  proc_code            VARCHAR2(4),
  branch_code          VARCHAR2(10),
  parameters           VARCHAR2(2000),
  scheduled_start_date DATE,
  priority             NUMBER,
  proc_flag            VARCHAR2(2),
  fcu                  VARCHAR2(100),
  fcd                  DATE,
  lcu                  VARCHAR2(100),
  lcd                  DATE,
  job_no               NUMBER,
  job_source_module    VARCHAR2(4),
  start_date           DATE,
  end_date             DATE,
  created_user         VARCHAR2(100),
  created_date         DATE default SYSDATE,
  updated_user         VARCHAR2(100),
  updated_date         DATE default SYSDATE
);

comment on table gradata.GRAS_BATCH_PLAN
  is '批次任务执行表';
comment on column gradata.GRAS_BATCH_PLAN.sequence
  is '流水号';
comment on column gradata.GRAS_BATCH_PLAN.proc_code
  is '批处理代码';
comment on column gradata.GRAS_BATCH_PLAN.branch_code
  is '机构代码';
comment on column gradata.GRAS_BATCH_PLAN.parameters
  is '批处理参数';
comment on column gradata.GRAS_BATCH_PLAN.scheduled_start_date
  is '任务计划启动时间';
comment on column gradata.GRAS_BATCH_PLAN.priority
  is '优先级';
comment on column gradata.GRAS_BATCH_PLAN.proc_flag
  is '批处理状态';
comment on column gradata.GRAS_BATCH_PLAN.fcu
  is '创建人';
comment on column gradata.GRAS_BATCH_PLAN.fcd
  is '创建日期';
comment on column gradata.GRAS_BATCH_PLAN.lcu
  is '修改人';
comment on column gradata.GRAS_BATCH_PLAN.lcd
  is '创建日期';
comment on column gradata.GRAS_BATCH_PLAN.job_no
  is 'job号';
comment on column gradata.GRAS_BATCH_PLAN.job_source_module
  is 'job模块号';
comment on column gradata.GRAS_BATCH_PLAN.start_date
  is '任务起始时间';
comment on column gradata.GRAS_BATCH_PLAN.end_date
  is '任务结束时间(不精确,间隔时间越大差异越大)';
comment on column gradata.GRAS_BATCH_PLAN.created_user
  is '录入人';
comment on column gradata.GRAS_BATCH_PLAN.created_date
  is '录入日期';
comment on column gradata.GRAS_BATCH_PLAN.updated_user
  is '修改人 ';
comment on column gradata.GRAS_BATCH_PLAN.updated_date
  is '修改日期';

alter table GRADATA.GRAS_BATCH_PLAN
  add constraint PK_GRAS_BATCH_PLAN primary key (SEQUENCE);

  
create table GRADATA.GRAS_ASSIGN_BATCH_RECORD
(
  branch_code  VARCHAR2(10) not null,
  due_month    DATE not null,
  batch_code   VARCHAR2(4) not null,
  batch_seq    VARCHAR2(10),
  finish_flag  VARCHAR2(1),
  pk_serial    VARCHAR2(10) not null,
  created_user VARCHAR2(100) not null,
  created_date DATE default SYSDATE not null,
  updated_user VARCHAR2(100) not null,
  updated_date DATE default SYSDATE not null
);

comment on table GRADATA.GRAS_ASSIGN_BATCH_RECORD
  is '机构分单批次申请记录表';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.branch_code
  is '机构代码';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.due_month
  is '应缴月';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.batch_code
  is '批处理代码';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.batch_seq
  is '批处理流水';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.finish_flag
  is '完成状态';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.pk_serial
  is '数据主键';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.created_user
  is '录入人';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.created_date
  is '录入日期';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.updated_user
  is '修改人';
comment on column GRADATA.GRAS_ASSIGN_BATCH_RECORD.updated_date
  is '修改日期';

alter table gradata.GRAS_ASSIGN_BATCH_RECORD
add constraint PK_GRAS_ASSIGN_BATCH_RECORD primary key (BRANCH_CODE,DUE_MONTH,BATCH_CODE);
alter table gradata.GRAS_ASSIGN_BATCH_RECORD
  add constraint FK_GRAS_ASS_BA_REC_BR_CO foreign key (BRANCH_CODE)
  references SLISINTF.BRANCH_INFO(BRANCH_CODE);  
  
create table gradata.GRAS_BATCH_ERROR_RECORD
(
  sequence       VARCHAR2(10) not null,
  proc_code      VARCHAR2(4) not null,
  ctrl_no        VARCHAR2(40),
  ora_error_code NUMBER(6),
  error_message  VARCHAR2(300),
  operating_user VARCHAR2(100),
  operating_date DATE,
  sid            NUMBER,
  serial         NUMBER,
  branch_code    VARCHAR2(10)
);
-- Add comments to the table 
comment on table GRADATA.GRAS_BATCH_ERROR_RECORD
  is '系统批处理出错信息表';
-- Add comments to the columns 
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.sequence
  is '流水号-用于对应执行信息表数据';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.proc_code
  is '批处理代码';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.ctrl_no
  is '出错控制号';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.ora_error_code
  is 'ORA出错代码';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.error_message
  is '出错信息';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.operating_user
  is '操作执行用户';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.operating_date
  is '操作执行时间';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.sid
  is '运行该JOB的SID';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.serial
  is 'SID对应的SERIAL#';
comment on column GRADATA.GRAS_BATCH_ERROR_RECORD.branch_code
  is '机构代码';
alter table GRADATA.GRAS_BATCH_ERROR_RECORD
  add constraint PK_GRAS_BATCH_ERROR_RECORD primary key (SEQUENCE);  
  
  
  
create table GRADATA.GRAS_ASSIGN_FAILED_RECORD
(
  operate_type        VARCHAR2(1) not null,
  policy_no           VARCHAR2(20) not null,
  failed_type         VARCHAR2(2) not null,
  batch_seq           VARCHAR2(10),
  pk_serial           VARCHAR2(10) not null,
  created_user        VARCHAR2(100) not null,
  created_date        DATE default SYSDATE not null,
  updated_user        VARCHAR2(100) not null,
  updated_date        DATE default SYSDATE not null
);
comment on table gradata.GRAS_ASSIGN_FAILED_RECORD
  is '分单失败保单记录表';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.operate_type
  is '操作类型:1-手动;0-自动';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.policy_no
  is '保单号';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.failed_type
  is '分单失败类型';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.batch_seq
  is '批处理流水号';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.pk_serial
  is '数字主键';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.created_user
  is '录入人 ';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.created_date
  is '录入日期';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.updated_user
  is '修改人';
comment on column gradata.GRAS_ASSIGN_FAILED_RECORD.updated_date
  is '修改日期';
alter table gradata.GRAS_ASSIGN_FAILED_RECORD
  add constraint PK_GRAS_ASSIGN_FAILED_RECORD primary key (PK_SERIAL);
alter table gradata.GRAS_ASSIGN_FAILED_RECORD
  add constraint FK_GRAS_ASS_FAIL_REC_POL_NO foreign key (POLICY_NO)
  references SLISINTF.POLICY(POLICY_NO);
alter table gradata.GRAS_ASSIGN_FAILED_RECORD
  add constraint FK_GRAS_ASS_FAIL_REC_FAIL_TY foreign key (FAILED_TYPE)
  references GRARULE.GRAS_ASSIGN_FAILED_TYPE(FAILED_TYPE);

create public synonym GRAS_BRANCH_ASSIGN_RULE               for gradata.GRAS_BRANCH_ASSIGN_RULE;
create public synonym GRAS_AREA_STAFF                       for gradata.GRAS_AREA_STAFF;
create public synonym GRAS_POLICY_GEO                       for gradata.GRAS_POLICY_GEO;
create public synonym GRAS_BRANCH_GEO                       for gradata.GRAS_BRANCH_GEO;
create public synonym GRAS_BANK_GEO                         for gradata.GRAS_BANK_GEO;
create public synonym GRAS_BANK_EMP                         for gradata.GRAS_BANK_EMP;
create public synonym GRAS_BRANCH_STYLE                     for gradata.GRAS_BRANCH_STYLE;
create public synonym GRAS_ASSIGN_RULE_CHGS                 for gradata.GRAS_ASSIGN_RULE_CHGS;
create public synonym GRAS_DEPT_SERVICER                    for gradata.GRAS_DEPT_SERVICER;
create public synonym GRAS_BRANCH_SERVICER                  for gradata.GRAS_BRANCH_SERVICER;
create public synonym GRAS_POLICY_SERVICER_ASSIGN           for gradata.GRAS_POLICY_SERVICER_ASSIGN;
create public synonym GRAS_SYS_ROLE                         for gradata.GRAS_SYS_ROLE;
create public synonym GRAS_SYS_ROLE_MENU                    for gradata.GRAS_SYS_ROLE_MENU;
create public synonym GRAS_SYS_MENU                         for gradata.GRAS_SYS_MENU;
create public synonym GRAS_SYS_DATA_TRANS                   for gradata.GRAS_SYS_DATA_TRANS;
create public synonym GRAS_ASSIGN_FAILED_RECORD             for gradata.GRAS_ASSIGN_FAILED_RECORD;
create public synonym GRAS_BATCH_PLAN            			for gradata.GRAS_BATCH_PLAN;
create public synonym GRAS_ASSIGN_BATCH_RECORD            	for gradata.GRAS_ASSIGN_BATCH_RECORD;
create public synonym GRAS_BATCH_ERROR_RECORD            	for gradata.GRAS_BATCH_ERROR_RECORD;



grant select,insert,update on gradata.GRAS_BRANCH_ASSIGN_RULE      to gracde,graopr;
grant select,insert,update on gradata.GRAS_AREA_STAFF              to gracde,graopr;
grant select,insert,update on gradata.GRAS_POLICY_GEO              to gracde,graopr;
grant select,insert,update on gradata.GRAS_BRANCH_GEO              to gracde,graopr;
grant select,insert,update on gradata.GRAS_BANK_GEO                to gracde,graopr;
grant select,insert,update on gradata.GRAS_BANK_EMP                to gracde,graopr;
grant select,insert,update on gradata.GRAS_BRANCH_STYLE            to gracde,graopr;
grant select,insert,update on gradata.GRAS_ASSIGN_RULE_CHGS        to gracde,graopr;
grant select,insert,update on gradata.GRAS_DEPT_SERVICER           to gracde,graopr;
grant select,insert,update on gradata.GRAS_BRANCH_SERVICER         to gracde,graopr;
grant select,insert,update on gradata.GRAS_POLICY_SERVICER_ASSIGN  to gracde,graopr;
grant select,insert,update on gradata.GRAS_SYS_ROLE                to gracde,graopr;
grant select,insert,update on gradata.GRAS_SYS_ROLE_MENU           to gracde,graopr;
grant select,insert,update on gradata.GRAS_SYS_MENU                to gracde,graopr;
grant select,insert,update on gradata.GRAS_SYS_DATA_TRANS          to gracde,graopr;
grant select,insert,update on gradata.GRAS_ASSIGN_FAILED_RECORD    to gracde,graopr;
grant select,insert,update on gradata.GRAS_BATCH_PLAN    		   to gracde,graopr;
grant select,insert,update on gradata.GRAS_ASSIGN_BATCH_RECORD     to gracde,graopr;
grant select,insert,update on gradata.GRAS_BATCH_ERROR_RECORD      to gracde,graopr;