title: Can BigQuery API overwrite existing table/view with create_table() (tables insert)?
body: <p>I'm using the <a href="https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.client.Client.html#google.cloud.bigquery.client.Client.create_table" rel="nofollow noreferrer">Python client create_table() function</a> which calls the underlying <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/insert" rel="nofollow noreferrer">tables insert API</a>. There is an <code>exists_ok</code> parameter but this causes the function to simply ignore the create if the table already exists. The problem with this is that when creating a view, I would like to <em>overwrite</em> the existing view SQL if it's already there. What I'm currently doing to get around this is:</p>
  
  <pre><code>if overwrite:
      bq_client.delete_table(view, not_found_ok=True)
  
  view = bq_client.create_table(view)
  </code></pre>
  
  <p>What I don't like about this is there are potentially several seconds during which the view no longer exists. And if the code dies for whatever reason after the delete but before the create then the view is effectively gone.</p>
  
  <p><strong>My question</strong>: is there a way to create a table (view) such that it overwrites any existing object? Or perhaps I have to detect this situation and run some kind of <code>update_table()</code> (<a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/patch" rel="nofollow noreferrer">patch</a>)?</p>