COPY (SELECT building_id, ref_toid, ref_osm_id, revision_id, location_name, location_number, location_street, location_line_two, location_town, location_postcode, location_address_source, location_address_links, location_latitude, location_longitude, current_landuse_group, current_landuse_order, building_attachment_form, date_change_building_use, date_year, date_lower, date_upper, date_source, date_source_detail, date_link, facade_year, facade_upper, facade_lower, facade_source, facade_source_detail, size_storeys_attic, size_storeys_core, size_storeys_basement, size_storeys_source_type, size_storeys_source_links, size_height_apex, size_height_apex_source_type, size_height_apex_source_links, size_height_eaves, size_height_eaves_source_type, size_height_eaves_source_links, size_floor_area_ground, size_floor_area_total, size_floor_area_source_type, size_floor_area_source_links, size_width_frontage, sust_breeam_rating, sust_dec, sust_retrofit_date, construction_core_material, construction_secondary_materials, construction_roof_covering, planning_portal_link, planning_in_conservation_area_id, planning_in_conservation_area_url, planning_in_conservation_area_source_url, planning_conservation_area_name, planning_in_list, planning_list_id, planning_list_cat, planning_list_grade, planning_heritage_at_risk_url, planning_world_list_id, planning_glher_url, planning_in_apa_url, planning_local_list_url, planning_historic_area_assessment_url, is_domestic, is_domestic_source, is_domestic_links, community_type_worth_keeping_total, likes_total, survival_status, survival_source, survival_source_links, disaster_type, disaster_severity, disaster_assessment_method, disaster_source_link, disaster_start_date, disaster_end_date, size_far_ratio, size_far_ratio_source_type, size_far_ratio_source_links, size_plot_area_total, size_plot_area_total_source_type, size_plot_area_total_source_links, size_parcel_geometry, size_parcel_geometry_source_type, size_parcel_geometry_source_links, context_front_garden, context_back_garden, context_flats_garden, context_garden_source_type, context_garden_source_type, context_street_width, context_street_width_source_type, context_street_width_source_links, context_pavement_width, context_pavement_width_source_type, context_pavement_width_source_links, context_street_geometry, context_street_geometry_source_type, context_street_geometry_source_links, context_green_space_distance, context_green_space_distance, context_green_space_distance_source_links, context_tree_distance, context_tree_distance_source_type, ccontext_tree_distance_source_links FROM buildings) TO '/tmp/building_attributes.csv' WITH CSV HEADER