---
url: https://honeycombmaps.com/docs/snowflake-native-app/accessing-map-metadata-with-sql-queries.md
description: >-
  Query map metadata, which is stored in Snowflake Hybrid Tables in your
  account, directly with SQL.
---

# Accessing Map Metadata with SQL Queries

## Overview

Honeycomb Maps stores all map data and metadata in Snowflake Hybrid Tables within your Snowflake account. These tables are accessible to admin users and support the application's enterprise-grade permissions system. Because metadata is stored in standard Snowflake tables, you can use SQL queries to access, analyze, and manage map information.

## Benefits

Storing metadata in Snowflake Hybrid Tables provides several advantages:

* **Direct SQL access**: Query map metadata using standard Snowflake SQL
* **Data portability**: Copy tables for backup or integration purposes
* **Automation support**: Populate or manage data using tools like dbt
* **Increased reliability**: Data persists independently of the application
* **Integration capabilities**: Connect map metadata to existing data workflows and reporting systems

## Available Metadata Tables

Admin users can access the following tables:

### MAPS Table

Contains metadata for all maps created in Honeycomb Maps.

### USERS Table

Tracks all users who have accessed the application.

### MAP_PERMISSIONS Table

Stores permission assignments that control map access and editing rights.

### MAP_HISTORY Table

Tracks historical changes and modifications to maps.

## Querying Metadata

Admin users can query these tables using standard SQL syntax through any Snowflake interface, including Snowsight, SnowSQL, or programmatic connections.

## Cloning data between Honeycomb Maps instances

Data may need to be transferred between different instances of the Honeycomb Maps application, for example to set up an application for UAT testing.

**Prerequisites:**

* The 'HONEYCOMB_APP_ADMIN' or application role (or ownership of the application) on both the source and target applications

**Instructions:**

1. Get the application names for the old instance (`<SOURCE_APP_NAME>`) and the new instance (`<DESTINATION_APP_NAME>`). This SQL statement shows the names of all installed applications.
   ```sql
   SHOW APPLICATIONS;
   ```

2. Verify that you can query the old app metadata
   ```sql
   SELECT * FROM <SOURCE_APP_NAME>.CONFIG.MAPS; -- this will show the maps that will be transferred to the destination application
   ```

3. Run the following SQL transaction to transfer application metadata (select all sql statements below and run them all at once). Replace `<SOURCE_APP_NAME>` and `<DESTINATION_APP_NAME>` with the actual application names.

> **WARNING:** These queries will overwrite any existing maps in the `<DESTINATION_APP_NAME>` application.

```sql
-- Wrap all queries in a transaction so if any of them fail, then no changes are made
BEGIN TRANSACTION;

-- Step 1: Delete rows from metadata tables in destination application (child tables first)
DELETE FROM <DESTINATION_APP_NAME>.CONFIG.MAP_HISTORY;
DELETE FROM <DESTINATION_APP_NAME>.CONFIG.MAP_PERMISSIONS;
DELETE FROM <DESTINATION_APP_NAME>.CONFIG.MAPS;
DELETE FROM <DESTINATION_APP_NAME>.CONFIG.USERS;

-- Step 2: Load from source application to destination application in reverse order (parent tables first)
INSERT INTO <DESTINATION_APP_NAME>.CONFIG.USERS
SELECT * FROM <SOURCE_APP_NAME>.CONFIG.USERS;

INSERT INTO <DESTINATION_APP_NAME>.CONFIG.MAPS
SELECT * FROM <SOURCE_APP_NAME>.CONFIG.MAPS;

INSERT INTO <DESTINATION_APP_NAME>.CONFIG.MAP_PERMISSIONS
SELECT * FROM <SOURCE_APP_NAME>.CONFIG.MAP_PERMISSIONS;

INSERT INTO <DESTINATION_APP_NAME>.CONFIG.MAP_HISTORY
SELECT * FROM <SOURCE_APP_NAME>.CONFIG.MAP_HISTORY;

COMMIT;
```

6. Verify that maps in the new application load successfully for users.

### Example Queries

> **Note:** Replace `<HONEYCOMB_MAPS>` with the application name you specified when installing Honeycomb Maps.

View all maps:

```sql
SELECT * FROM <HONEYCOMB_MAPS>.CONFIG.MAPS;
```

View all users:

```sql
SELECT * FROM <HONEYCOMB_MAPS>.CONFIG.USERS;
```

View map permissions:

```sql
SELECT * FROM <HONEYCOMB_MAPS>.CONFIG.MAP_PERMISSIONS;
```

View map history:

```sql
SELECT * FROM <HONEYCOMB_MAPS>.CONFIG.MAP_HISTORY;
```

## Use Cases

### Backup and Recovery

Create backups of map metadata by copying tables to another database or schema:

```sql
CREATE TABLE BACKUP_DATABASE.BACKUP_SCHEMA.MAPS AS
SELECT * FROM <HONEYCOMB_MAPS>.CONFIG.MAPS;
```

### Reporting and Analytics

Join metadata tables with other Snowflake data sources to create custom reports on the number of maps created, users who have accessed the app, and permission distribution.

### Automation with dbt

Integrate Honeycomb Maps metadata into your dbt workflows to store map definitions as code in a version-control system (VCS) like GitHub.

### Auditing

Query the metadata tables to audit map ownership and changes, as well as permissions and permission changes.

## Permissions

Access to metadata tables is controlled by Honeycomb Maps application roles. Each role has specific permissions on the CONFIG schema tables:

### HONEYCOMB_APP_ADMIN Role

Users with the `HONEYCOMB_APP_ADMIN` application role have full permissions on all metadata tables:

* **USERS**: ALL privileges
* **MAPS**: ALL privileges
* **MAP_PERMISSIONS**: ALL privileges
* **MAP_HISTORY**: ALL privileges

### HONEYCOMB_APP_EDITOR Role

Users with the `HONEYCOMB_APP_EDITOR` application role have the following permissions:

* **USERS**: SELECT, INSERT, UPDATE
* **MAPS**: SELECT, INSERT, UPDATE
* **MAP_PERMISSIONS**: SELECT, INSERT, UPDATE, DELETE
* **MAP_HISTORY**: SELECT

### HONEYCOMB_APP_VIEWER Role

Users with the `HONEYCOMB_APP_VIEWER` application role have the following permissions:

* **USERS**: SELECT, INSERT, UPDATE (required for new user auto-enrollment)
* **MAPS**: SELECT
* **MAP_PERMISSIONS**: SELECT
* **MAP_HISTORY**: SELECT
