CREATE TABLE "FXKH_TXL"."ADDRESS_BOOK"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "NAME" VARCHAR(10) NOT NULL,
    "PHONE" VARCHAR(15),
    "TEL" VARCHAR(50),
    "FAXES" VARCHAR(50),
    "ORGANIZATION" VARCHAR(50),
    "POSITION" VARCHAR(200),
    "COMMENTS" VARCHAR(200),
    "URL" VARCHAR(200),
    "ADCD" VARCHAR(50),
    "SORT" INTEGER DEFAULT 0,
    "V" INTEGER DEFAULT 0,
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."ADDRESS_BOOK" IS '通讯录';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."COMMENTS" IS '备注';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."FAXES" IS '传真';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."NAME" IS '姓名';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."ORGANIZATION" IS '组织';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."PHONE" IS '手机号';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."ADCD" IS '行政区划';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."POSITION" IS '职务';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."SORT" IS '序号';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."TEL" IS '电话';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."URL" IS '图片路径';
COMMENT ON COLUMN "FXKH_TXL"."ADDRESS_BOOK"."V" IS '版本';


CREATE TABLE "FXKH_TXL"."ADINFO"
(
    "ADCD" CHAR(15) NOT NULL,
    "ADNM" VARCHAR(32) NOT NULL,
    NOT CLUSTER PRIMARY KEY("ADCD")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."ADINFO" IS '行政区划基础信息';
COMMENT ON COLUMN "FXKH_TXL"."ADINFO"."ADCD" IS '政区编码';
COMMENT ON COLUMN "FXKH_TXL"."ADINFO"."ADNM" IS '政区名称';


CREATE TABLE "FXKH_TXL"."UNIT_DICT"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "NAME" VARCHAR(50) NOT NULL,
    "SORT" INTEGER DEFAULT 0 NOT NULL,
    "O_ID" INTEGER NOT NULL,
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."UNIT_DICT" IS '单位字典表';
COMMENT ON COLUMN "FXKH_TXL"."UNIT_DICT"."NAME" IS '名称';
COMMENT ON COLUMN "FXKH_TXL"."UNIT_DICT"."SORT" IS '序号';
COMMENT ON COLUMN "FXKH_TXL"."UNIT_DICT"."O_ID" IS '组织类型Id';


CREATE TABLE "FXKH_TXL"."ORGANIZATION"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "OBJ_ID" VARCHAR(50) NOT NULL,
    "NAME" VARCHAR(50) NOT NULL,
    "SORT" INTEGER DEFAULT 0,
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."ORGANIZATION" IS '组织表';
COMMENT ON COLUMN "FXKH_TXL"."ORGANIZATION"."NAME" IS '名称';
COMMENT ON COLUMN "FXKH_TXL"."ORGANIZATION"."OBJ_ID" IS '编号';
COMMENT ON COLUMN "FXKH_TXL"."ORGANIZATION"."SORT" IS '序号';



CREATE TABLE "FXKH_TXL"."AB_UD_R"
(
    "AD_ID" INTEGER,
    "DICT_ID" INTEGER,
    "TYPE" CHAR(1),
    "SORT" INTEGER) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."AB_UD_R" IS '用户单位字典关联表';
COMMENT ON COLUMN "FXKH_TXL"."AB_UD_R"."AD_ID" IS '联系人id';
COMMENT ON COLUMN "FXKH_TXL"."AB_UD_R"."DICT_ID" IS '字典id';
COMMENT ON COLUMN "FXKH_TXL"."AB_UD_R"."TYPE" IS '0:组织,1:单位';
COMMENT ON COLUMN "FXKH_TXL"."AB_UD_R"."SORT" IS '序号';


CREATE TABLE "FXKH_TXL"."FC"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "USER_ID" INTEGER NOT NULL,
    "AB_ID" INTEGER NOT NULL,
    "SORT" INTEGER DEFAULT 0,
    "TYPE" CHAR(1),
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."FC" IS '常用联系人';
COMMENT ON COLUMN "FXKH_TXL"."FC"."AB_ID" IS '通讯录编号';
COMMENT ON COLUMN "FXKH_TXL"."FC"."SORT" IS '序号';
COMMENT ON COLUMN "FXKH_TXL"."FC"."TYPE" IS '0:常用联系人,1:置顶联系人';
COMMENT ON COLUMN "FXKH_TXL"."FC"."USER_ID" IS '用户编号';


CREATE TABLE "FXKH_TXL"."LOGIN_INFO"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "IP" VARCHAR(50),
    "CREATE_ID" VARCHAR(50),
    "CREATE_TIME" DATETIME(0),
    "TYPE" CHAR(1) NOT NULL,
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."LOGIN_INFO" IS '登录日志';
COMMENT ON COLUMN "FXKH_TXL"."LOGIN_INFO"."CREATE_ID" IS '新增人id';
COMMENT ON COLUMN "FXKH_TXL"."LOGIN_INFO"."CREATE_TIME" IS '新增时间';
COMMENT ON COLUMN "FXKH_TXL"."LOGIN_INFO"."TYPE" IS '0:密码登录 1:验证码登录';


CREATE TABLE "FXKH_TXL"."USERS"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "USERNAME" VARCHAR(50) NOT NULL,
    "PASSWORD" VARCHAR(50) NOT NULL,
    "SALT" VARCHAR(50) NOT NULL,
    "ROLE" VARCHAR(2) DEFAULT 0,
    "AB_ID" INTEGER,
    "LAST_DATE" DATETIME(0),
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."USERS" IS '用户表';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."AB_ID" IS '通讯录id';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."USERNAME" IS '用户名';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."ROLE" IS '0:普通管理员,1:政区管理员,99:系统管理员';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."PASSWORD" IS '密码';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."LAST_DATE" IS '最后登录时间';
COMMENT ON COLUMN "FXKH_TXL"."USERS"."SALT" IS '盐值';


CREATE TABLE "FXKH_TXL"."AB_INFO"
(
    "ID" INTEGER IDENTITY(1, 1) NOT NULL,
    "JSON" VARCHAR(2000),
    "AB_ID" INTEGER,
    "VERSION" INTEGER DEFAULT 0,
    "CREATE_ID" VARCHAR(50),
    "CREATE_TIME" DATETIME(0),
    "TYPE" CHAR(1) DEFAULT 0,
    NOT CLUSTER PRIMARY KEY("ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "FXKH_TXL"."AB_INFO" IS '通讯录操作日志';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."AB_ID" IS '通讯录编号';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."CREATE_ID" IS '新增人id';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."CREATE_TIME" IS '新增时间';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."JSON" IS '数据';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."TYPE" IS '0:添加用户,1:修改用户,2:修改权限,3:删除用户';
COMMENT ON COLUMN "FXKH_TXL"."AB_INFO"."VERSION" IS '版本号';


