# Using user attributes for dynamic schema and table name injection

Looker's
[User Attributes](https://docs.cloud.google.com/looker/docs/admin-panel-users-user-attributes)
feature can be used to dynamically insert schema and/or table names on a per-user
basis.


The first step is to
[create a user attribute](https://docs.cloud.google.com/looker/docs/admin-panel-users-user-attributes#creating_user_attributes),
such as `custom_schema` or `custom_table`, to which you
will assign a value for each user. You can assign these values:

- Through the UI
- In [bulk via the API](https://docs.cloud.google.com/looker/docs/reference/looker-api/latest/methods/UserAttribute/user_attribute)
- In the [SSO URL for embedded contexts](https://github.com/looker/looker_embed_sso_examples/blob/master/node_example.js#L31).


Once you have created the user attribute and assigned the appropriate value for
your users, you can add a reference to that attribute in the
`sql_table_name` of your view files, via
[Liquid variables](https://docs.cloud.google.com/looker/docs/liquid-variable-reference).
Following are two examples, one using a custom schema and one a custom table.

## Example A


Using a `custom_schema`:

```
view: events {
 sql_table_name: {{ _user_attributes['custom_schema'] }}.events ;;

 dimension: event_id {
   type: number
   primary_key: yes
   sql: ${TABLE}.id ;;
 }
}
```

## Example B


Using a `custom_table`:

```
view: events {
  sql_table_name: web_traffic.{{ _user_attributes['custom_event_table_name'] }} ;;

  dimension: event_id {
    type: number
    primary_key: yes
    sql: ${TABLE}.id ;;
 }
}
```