User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
sql_table_name (for Views)

This page refers to the sql_table_name parameter that is part of a view

sql_table_name can also be used as part of a join, described here

sql_table_name can also be used as part of an explore, described here

Usage

view: view_name {
  sql_table_name: table_name
}

Hierarchy

sql_table_name

Default Value

The name of the view

Accepts

A table name in your database

Special Rules

  • The table must be accessible within the database connection
  • If the table is in a different schema, the schema must be specified
  • If the table is in a different database, the database and schema must be specified and the other database must be on the same machine and be in the same SQL dialect

Definition

sql_table_name sets the table in your database that will be queried by a view. If you do not add a sql_table_name Looker defaults to the name of the view.

In other words, this:

view: my_name { … }

is logically equivalent to this:

view: my_name { sql_table_name: my_name ;; }

It is quite common to fall back on this default behavior, and not use sql_table_name. However, there are some major situations where it can be useful. First, in some cases you’ll simply want the view to have a different name than the underlying table, such as to clean up a messy table name:

view: order { sql_table_name: prod_orders_2 ;; }

Additionally, there are cases when a view needs to be based on a database or schema that is not the default. The default database and schema for any given connection is configured in the Admin section of Looker under Connections. You can then make references like this:

view: desired_view_name { sql_table_name: database_name.schema_name.table_name ;; }

Examples

Make the customer view rely on the customer_1 table from the default schema:

view: customer { sql_table_name: customer_1 ;; }

Make the customer view rely on the customer_1 table from the analytics schema:

view: customer { sql_table_name: analytics.customer_1 ;; }

Common Challenges

Tables Referenced By view Must Be Accessible From The Current Connection

views are referenced by an explore or join parameter, which in turn is referenced by a model. The model determines which database connection is used (see connection for model). Database connections themselves are defined in the Admin section of Looker. When you reference a table in the sql_table_name parameter, the table needs to be accessible within the associated connection.

Top