sql_table_name (for Explores)

Stay organized with collections Save and categorize content based on your preferences.

This page refers to the sql_table_name parameter that is part of an Explore.

sql_table_name can also be used as part of a view, described on the sql_table_name (for views) parameter documentation page.

sql_table_name can also be used as part of a join, described on the sql_table_name (for joins) parameter documentation page.

Usage

explore: explore_name {
  sql_table_name: table_name ;;
}
Hierarchy
sql_table_name
Default Value
The database table on which the Explore's view is based

Accepts
The name of a database table

Special Rules
  • sql_table_name should only be used when the same view can describe multiple tables
  • Any table referenced by sql_table_name must be accessible within the database connection of its model

Definition

sql_table_name sets the table in your database that will be queried by the Explore. Typically the view for which an Explore is named defines the table that will be queried. However, in cases where multiple tables have the same structure, the same view can be used to describe all of them. sql_table_name lets you specify which of those tables should be used.

If you need to reference a table from a different database/schema, you can use database_or_schema_name.table_name. If you don't explicitly write a database/schema Looker will use the default that you have set. The default is configured in the Admin section of Looker under Connections.

Examples

Make the customers Explore rely on the customer_1 table from the default database/schema:

explore: customers {
  sql_table_name: customer_1 ;;
}

Make the customers Explore rely on the customer_1 table from the analytics database/schema:

explore: customers {
  sql_table_name: analytics.customer_1 ;;
}

Common challenges

Tables referenced by sql_table_name must be accessible from the current connection

sql_table_name is part of an Explore, which is in turn part of a model. The model will have a database connection defined in it. Any table you reference in sql_table_name must be accessible within that database connection.

Things to know

To name a view differently than the underlying table, apply sql_table_name at the view level

Using sql_table_name at the explore level, as described on this page, is not very common. It should only be used when the same view can describe multiple tables.

The more typical method is to use sql_table_name at the view level when you want to name a view differently than the underlying table name.

In other words, instead of this:

Model File

explore: customers {
  sql_table_name: customer_1 ;;
}

Do this:

Model File

explore: customers { ... }

View File

view: customers {
  sql_table_name: customer_1 ;;
}