-- auto-generated definition
create table adhoc.tbl_abp_import
(
    source_id                         varchar(20),
    uprn                              bigint not null
        constraint tbl_abp_import_pk
            primary key,
    usrn                              bigint,
    address_logical_status            smallint,
    address_logical_status_desc       varchar(200),
    building_logical_status           smallint,
    building_logical_status_desc      varchar(200),
    building_status                   smallint,
    building_status_desc              varchar(200),
    building_classification_code      varchar(25),
    building_classification_code_desc varchar(200),
    organisation_name                 varchar(100),
    sao                               varchar(105),
    sao_text                          varchar(90),
    sao_start_number                  smallint,
    sao_start_suffix                  varchar(2),
    sao_end_number                    smallint,
    sao_end_suffix                    varchar(2),
    pao                               varchar(105),
    pao_text                          varchar(90),
    pao_start_number                  smallint,
    pao_start_suffix                  varchar(2),
    pao_end_number                    smallint,
    pao_end_suffix                    varchar(2),
    administrative_area               varchar(30),
    street_description                varchar(110),
    postcode                          varchar(8),
    postcode_area                     varchar(2),
    postcode_district                 varchar(4),
    postcode_sector                   varchar(6),
    locality_name                     varchar(40),
    town_name                         varchar(30),
    parent_uprn                       bigint,
    multi_occ_count                   smallint,
    x_coordinate                      varchar(15),
    y_coordinate                      varchar(15),
    wgs84_longitude                   varchar(20),
    wgs84_latitude                    varchar(20),
    rpc                               smallint,
    postal_address                    varchar(1),
    address_start_date_time           timestamp,
    address_end_date_time             timestamp,
    last_update_date_time             timestamp,
    entry_date_time                   timestamp,
    os_topo_toid                      varchar(20),
    building_premise_count            integer,
    valid_address_flag                varchar(1),
    dna_address_type                  varchar(20),
    building_type                     varchar(20),
    iud_indicator                     varchar(1),
    row_start_date_time               timestamp,
    row_end_date_time                 timestamp,
    row_is_current                    varchar(1)
);

alter table adhoc.tbl_abp_import
    owner to postgres;

create index tbl_abp_import_postcode_idx
    on adhoc.tbl_abp_import (postcode);

