Thanks for the question. You wrote “query the database“; I assume that means you need some SQL help.
Here’s the simplest query I can think of:
SELECT <code>wp_terms</code>.*, <code>wp_term_taxonomy</code>.* FROM <code>wp_terms</code> LEFT JOIN <code>wp_term_taxonomy</code> ON <code>wp_terms</code>.<code>term_id</code> = <code>wp_term_taxonomy</code>.<code>term_id</code> WHERE wp_term_taxonomy.taxonomy = 'attachment_category'
NOTE: the <code> and </code> literals in the above example must be replaced by “backtick” characters.
You may have to change the wp_ prefix, but the rest should work. You will get all the information there is. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestion.