How can I write in RPostgreSQL's dbListTables() function to get the same results as PostgreSQL's native /dt *name_pattern* command?

I have connected to my company's PostgreSQL database using the RPostgarSQL package. I would like to list tables that match certain naming patterns using the dbListTable() function. In native PostgreSQL environment, I can just use psql command

\dt *name_pattern* 

to find tables. How can I do the same thing using RPostgreSQL::dbListTable()?

Answers


Most of the information you can get from psql's \d... commands comes from the tables in information_schema. In your case you can do this:

SELECT table_name
FROM   information_schema.tables
WHERE  table_name LIKE '%foo%'

Need Your Help

Dynamic search filter with multiple factors in web app

mysql spring-mvc search stored-procedures filter

I'm building a real estate website and I'm a little bit confused on how to filter apartment search results. The user can filter his search by clicking on check boxes and a textbox that contains key...

jsf - intercept when user departs page

jsf page-lifecycle

I have the following 3 simple pages in a JSF app.