How to delete Drupal Views programmatically

Last updated on 19/01/2018

Here is a simple function which will delete the views from DataBase

For Drupal 8 see https://drupal.stackexchange.com/a/225907/13633

function _delete_view($views_id, $views_name = '') {
  db_delete('views_view')
    ->condition('vid', $views_id)
    ->execute();
 
  if ($views_name) {
    // Or make one additional query in function.
    cache_clear_all("views_query:$views_name", 'cache_views');
  }
 
  // Clear views caches.
  views_invalidate_cache();
}