Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on
06-09-2023
05:57 AM
- last edited on
04-21-2026
12:08 AM
by
GrazittiAPI
Hello,
How do we fetch the number of columns each table has in each DB from HMS DB?
I have an urgent need to do a comparison for the number of columns each table has in each DB between 2 clusters. Doing that manually is practically impossible.
Kindly help
Thanks
snm1523
Created 06-09-2023 08:47 AM
@snm1523 From beeline
use sys;
select cd_id, count(cd_id) as column_count from columns_v2 group by cd_id order by cd_id asc; -- this will return column_count for each tableEvery individual table will have a unique cd_id. To map the table names with cd_id, try the following.
select t.tbl_name, s.cd_id from tbls t join sds s where t.sd_id=s.sd_id order by s.cd_id asc;You could also merge the two queries to get the o/p together.
Created 06-09-2023 08:47 AM
@snm1523 From beeline
use sys;
select cd_id, count(cd_id) as column_count from columns_v2 group by cd_id order by cd_id asc; -- this will return column_count for each tableEvery individual table will have a unique cd_id. To map the table names with cd_id, try the following.
select t.tbl_name, s.cd_id from tbls t join sds s where t.sd_id=s.sd_id order by s.cd_id asc;You could also merge the two queries to get the o/p together.
Created 06-09-2023 09:36 AM
Thank you again @smruti 😊