title | redirect_from | ||
---|---|---|---|
Adding and managing databases |
|
Connect Metabase to your data sources.
To add a database connection, click on the gear icon in the top right, and navigate to Admin settings > Databases > Add a database.
Fill out the fields for that database, and click Save changes at the bottom.
The connection settings differ database to database. For the list of connection settings available for your database, click on the link to your database below.
The databases listed below have official drivers maintained by the Metabase team. Customers on paid plans will get official support.
- Amazon Athena
- BigQuery (Google Cloud Platform)
- Druid
- Google Analytics
- H2
- MongoDB (version 4.2 or higher)
- MySQL (version 5.7 or higher, as well as MariaDB version 10.2 or higher)
- Oracle
- PostgreSQL
- Presto
- Redshift (Amazon Web Services)
- Snowflake
- SparkSQL
- SQL Server
- SQLite
- Vertica
If you don't see your database listed here, see partner and community drivers.
For provider-specific connection details, like connecting to a PostgreSQL data warehouse on RDS:
Metabase runs syncs and scans to stay up to date with your database.
- Syncs get updated schemas to display in the Data Browser.
- Scans take samples of column values to populate filter dropdown menus and suggest helpful visualizations. Metabase does not store complete tables from your database.
When Metabase first connects to your database, it performs a scan to determine the metadata of the columns in your tables and automatically assign each column a semantic type.
During the scan, Metabase also takes a sample of each table to look for URLs, JSON, encoded strings, etc. You can map table and column metadata to new values from Admin settings > Data model. Check out editing metadata.
Turn this option ON to manage the queries that Metabase uses to stay up to date with your database.
If you've selected Choose when syncs and scans happen > ON, you'll see the following options under Database syncing:
- Scan sets the frequency of the sync query to hourly (default) or daily.
- at sets the time when your sync query will run against your database (in the timezone of the server where your Metabase app is running).
If you've selected Choose when syncs and scans happen > ON, you'll see the following options under Scanning for filter values:
- Regularly, on a schedule allows you to run scan queries at a frequency that matches the rate of change to your database. The time is set in the timezone of the server where your Metabase app is running. This is the best option for a small database, or tables with distinct values that get updated often.
- Only when adding a new filter widget is a great option if you want scan queries to run on demand. Turning this option ON means that Metabase will only scan and cache the values of the field(s) that are used when a new filter is added to a dashboard or SQL question.
- Never, I'll do this manually if I need to is an option for databases that are either prohibitively large, or which never really have new values added. Use the Re-scan field values now button to run a manual scan and bring your filter values up to date.
A Metabase sync is a query that gets a list of updated table and view names, column names, and column data types from your database. This query runs against your database during setup, and again every hour by default. This scanning query is fast with most relational databases, but can be slower with MongoDB and some community-built database drivers. Syncing can't be turned off completely, otherwise Metabase wouldn't work.
A Metabase scan is a query that caches the column values for filter dropdowns by looking at the first 1,000 distinct records from each table, in ascending order. For each record, Metabase only stores the first 100 kilobytes of text, so if you have data with 1,000 characters each (like addresses), and your column has more than 100 unique addresses, Metabase will only cache the first 100 values from the scan query.
Cached column values are displayed in filter dropdown menus. If people type in the filter search box for values that aren't in the first 1,000 distinct records or 100kB of text, Metabase will run a query against your database to look for those values on the fly.
A scan is more intensive than a sync query, so it only runs once during setup, and again once a day by default. If you disable scans entirely, you'll need to bring things up to date by running manual scans.
To reduce the number of tables and fields Metabase needs to scan in order to stay current with your connected database, Metabase will only scan values for fields that someone has queried in the last fourteen days.
- Go to Admin settings > Databases > your database.
- Click on Sync database schema now.
To scan values from all the columns in a table:
- Go to Admin settings > Data model > your database.
- Select the table that you want to bring up to date with your database.
- Click the gear icon at the top of the page.
- Click Re-scan this table.
To scan values from a specific column:
- Go to Admin settings > Data model > your database.
- Select the table and find the column you want bring up to date with your database.
- Click the gear icon in the panel for that column.
- Click Re-scan this field.
To forget the data that Metabase has stored from previous database scans:
- Go to Admin settings > Data model > your database.
- Select the table.
- Optional: select the column.
- Click the gear icon.
- Click Discard cached field values.
Metabase syncs and scans regularly, but if the database administrator has just changed the database schema, or if a lot of data is added automatically at specific times, you may want to write a script that uses the Metabase API to force a sync or scan. Our API provides two ways to initiate a sync or scan of a database:
- Using a session token: the
/api/database/:id/sync_schema
orapi/database/:id/rescan_values
endpoints. These endpoints do the same things as going to the database in the Admin Panel and choosing Sync database schema now or Re-scan field values now respectively. To use these endpoints, you have to authenticate with a user ID and pass a session token in the header of your request. - Using an API key:
/api/notify/db/:id
. We created this endpoint so that people could notify their Metabase to sync after an ETL operation finishes. To use this endpoint, you must pass an API key by defining theMB_API_KEY
environment variable.
Caution: Deleting a database is irreversible! All saved questions and dashboard cards based on the database will be deleted as well!
Go to Admin settings > Databases > your database and click Remove this database.
If you've deleted the Metabase Sample Database, go to Admin settings > Databases and click Bring the Sample Database back.
- Troubleshooting database connections
- Troubleshooting syncs, scans, and fingerprinting
- Search or ask the Metabase community.
- Search for known bugs or limitations.