If you accidentally deleted a table in BigQuery, don’t worry just yet! There’s a way to recover it, but a few conditions apply:
1. The table was deleted within the last 7 days.
2. You know the name of the table and the dataset it was in.
To restore a table, use the first command from the screenshot in Cloud Shell.
For recovering views, you can use the Logs Explorer. Run the second query from the screenshot to search for update operations, which will show all updates to the view with the specified name. Find the correct query, copy it, and recreate the view manually.
Prevent Future Data Loss:
1. Set up error logs for timely alerts on any issues.
2. Use unique names for tables and views to avoid naming conflicts.
3. Double-check table names before deleting—one typo can lead to serious issues.
If you work with GA4 to BigQuery exports, be sure to check out my SQL cheat sheet.