Search code examples
rdatabase-schemar-dbi

How to get the schema of a database with the DBI package


Is there a function in the DBI package to get information about the schema of a database?

I am working with a connection to an SQL Server with the DBI package and the odbc driver. The dbListTables functions allows to show the tables in a particular schema with the schema parameter, but I cannot find a way to query which schemas there are.


Solution

  • You could use the SQL query below.

    all_schemas <- DBI::dbGetQuery(conn, "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA")