# Export All Table List by SQL

**URL:** <https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922>\
**Category:** SQL Queries\
**Tags:** sql\
**Created:** [September 17, 2021, 3:45am UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922 "2021-09-17T03:45:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmiyoshi](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@mmiyoshi](https://discuss.rapid7.com/u/mmiyoshi)\
**Post date:** [September 17, 2021, 3:45am UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922/1 "2021-09-17T03:45:28Z")

</div>

I refered to a below blog.  
And then, I’d like to get list the latest registerd tables.  
Can I do it?

\*Tried to Query  
SELECT tablename FROM pg\_tables; → Error:The query is invalid.  
Not enough roles? My role is admin.

Referer: List of Database Tables ( [List of Database Tables](https://discuss.rapid7.com/t/list-of-database-tables/1757) )

Thanks

---

<div class="post-metadata">

**Author:** ![jordan\_sander1](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jordan\_sander1](https://discuss.rapid7.com/u/jordan_sander1)\
**Post date:** [September 21, 2021, 6:21pm UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922/2 "2021-09-21T18:21:12Z")

</div>

Please be sure your query references exact column(s) and table name(s). When running a SQL query from the in-product SQL Query Export report, please reference this documentation for available facts and dimensions that can be queried:  
[https://docs.rapid7.com/nexpose/understanding-the-reporting-data-model-facts/](https://docs.rapid7.com/nexpose/understanding-the-reporting-data-model-facts/)  
[https://docs.rapid7.com/nexpose/understanding-the-reporting-data-model-dimensions/](https://docs.rapid7.com/nexpose/understanding-the-reporting-data-model-dimensions/)

All of the exact table names and row names are listed in the above documentation.

The statement _SELECT tablename FROM pg\_tables;_ is going to be invalid because “tablename” and “pg\_tables” don’t exist in the reporting data model - you need to replace “pg\_tables” with the table you are querying, and replace “tablename” with the column of the table you’re selecting.

---

<div class="post-metadata">

**Author:** ![mmiyoshi](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@mmiyoshi](https://discuss.rapid7.com/u/mmiyoshi)\
**Post date:** [September 22, 2021, 1:09am UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922/3 "2021-09-22T01:09:33Z")

</div>

Jordan-san

Thank you for Newly reference.  
But I wanted to get All Table List as using " \*pg\_tables".  
Because each tables messed up enable/disable on InsightVM Console GUI. Is there or not a issue with the table config or other setting etc ?  
In any case, I can continue these investigation by Newly reference.

Thanks.

---

<div class="post-metadata">

**Author:** ![jordan\_sander1](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jordan\_sander1](https://discuss.rapid7.com/u/jordan_sander1)\
**Post date:** [September 22, 2021, 2:16pm UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922/4 "2021-09-22T14:16:05Z")

</div>

The reporting data model is a dimensional model meant for reporting, and cannot be queried in the way you are attempting. All of the table names and their associated columns are listed in the Facts and Dimensions documentation I linked.

You can only accomplish _SELECT tablename FROM pg\_tables;_ from the console CLI in the unlocked underlying database. I don’t recommend running queries from there without Rapid7 Support guidance, as you could easily damage the underlying database.

For more info on the RDM please read this: [Understanding the reporting data model: Overview and query design | InsightVM Documentation](https://docs.rapid7.com/insightvm/understanding-the-reporting-data-model-overview-and-query-design/)

---

<div class="post-metadata">

**Author:** ![mmiyoshi](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/m/f6c823/32.png) [@mmiyoshi](https://discuss.rapid7.com/u/mmiyoshi)\
**Post date:** [September 27, 2021, 12:00am UTC](https://discuss.rapid7.com/t/export-all-table-list-by-sql/6922/5 "2021-09-27T00:00:40Z")

</div>

Jordan-san

Thank you very much !  
I understood Rapid7 Dimentional Model Specification.

Thanks.
