How to delete all categories programatically?

Please have look on the below code block-

$args = array(
    "hide_empty" => 0,
    "type"       => "post",
    "orderby"    => "name",
    "order"      => "ASC"
);
$types = get_categories($args);

foreach ( $types as $type) {
    wp_delete_category( $type->ID );
}

The function wp_delete_category will delete a single category. So we need to run a loop through $types to delete each single category.

Hope that helps.