$ bash drop-spanner-tables.sh <your project> <your spanner instance> <your spanner database>
Created
April 21, 2022 08:16
-
-
Save tkuchiki/57b6a3d5972e63daba562f0cc566be3e to your computer and use it in GitHub Desktop.
Drop Spanner tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
project="${1}" | |
instance="${2}" | |
database="${3}" | |
tables="SELECT | |
table_name | |
FROM | |
information_schema.tables | |
WHERE | |
table_schema = ''" | |
for table in $(gcloud --project=${project} spanner databases execute-sql ${database} --instance=${instance} --sql="${tables}" | awk 'NR>1'); do | |
gcloud --project=${project} spanner databases execute-sql ${database} --instance=${instance} --sql="DROP TABLE ${table}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment