Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

How to drop large number of tables from a schema using script in efficient and fast.



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)
beeline -u "jdbc:hive2://;principal=hive/;" -e "drop table schemaDB.$tableName" >> $drop.log



Thanks praKodi


Super Collaborator

hi @prakodi  You can use below string 5000 times


beeline -u "jdbc:hive2://;principal=hive/;" -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.

Super Collaborator

If you want to delete all the tables in a database in one go


  DROP DATABASE database_name CASCADE; 

Community Manager

@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!


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:
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.