Support Questions

Find answers, ask questions, and share your expertise

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

avatar
Explorer

 

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

3 REPLIES 3

avatar
Guru

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.

avatar
Guru

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

 

  DROP DATABASE database_name CASCADE; 

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


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: