0

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()?

QY Luo
  • 331
  • 1
  • 4
  • 11
  • 2
    Write a function that calls `dbListTable` and then filters the list using a regex and `grepl`. – joran Mar 15 '16 at 17:00

1 Answers1

3

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%'
Paul A Jungwirth
  • 23,504
  • 14
  • 74
  • 93