- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to drop large number of tables from a schema using script in efficient and fast.
- Labels:
-
Apache Hive
Created 01-16-2023 07:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I need to drop around 5000 tables from a schema - schemaDB, am using below script, tableNameList list contains all the 5000 tables names which I need to drop from the schema, but as the loop calling beeline process each time for each drop, the process to drop all the 5000 tables is taking lot of time, do we have another option where we can acheive it fastly.
for tableName in $(cat tableNameList)
do
beeline -u "jdbc:hive2://server1.com:10000/default;principal=hive/server1.com@.com;" -e "drop table schemaDB.$tableName" >> $drop.log
done
Thanks praKodi
Created 01-18-2023 12:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @prakodi You can use below string 5000 times
beeline -u "jdbc:hive2://server1.com:10000/default;principal=hive/server1.com@.com;" -e "drop table schemaDB.$tableName1" -e "drop table schemaDB.$tableName2" -e " "drop table schemaDB.$tableName3" ................ >> $drop.log
Please mark this as RESOLVED,if your queries are answered.
Created 01-18-2023 01:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to delete all the tables in a database in one go
DROP DATABASE database_name CASCADE;
Created 01-23-2023 02:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@prakodi Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future., thanks!
Regards,
Diana Torres,Community Moderator
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:
