[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-31。"],[],[],null,["# Using user attributes for dynamic schema and table name injection\n\nLooker's\n[User Attributes](/looker/docs/admin-panel-users-user-attributes)\nfeature can be used to dynamically insert schema and/or table names on a per-user\nbasis.\n\n\nThe first step is to\n[create a user attribute](/looker/docs/admin-panel-users-user-attributes#creating_user_attributes),\nsuch as `custom_schema` or `custom_table`, to which you\nwill assign a value for each user. You can assign these values:\n\n- Through the UI\n- In [bulk via the API](/looker/docs/reference/looker-api/latest/methods/UserAttribute/user_attribute)\n- In the [SSO URL for embedded contexts](https://github.com/looker/looker_embed_sso_examples/blob/master/node_example.js#L31).\n\n\nOnce you have created the user attribute and assigned the appropriate value for\nyour users, you can add a reference to that attribute in the\n`sql_table_name` of your view files, via\n[Liquid variables](/looker/docs/liquid-variable-reference).\nFollowing are two examples, one using a custom schema and one a custom table.\n\nExample A\n---------\n\n\nUsing a `custom_schema`: \n\n```\nview: events {\n sql_table_name: {{ _user_attributes['custom_schema'] }}.events ;;\n\n dimension: event_id {\n type: number\n primary_key: yes\n sql: ${TABLE}.id ;;\n }\n}\n```\n\nExample B\n---------\n\n\nUsing a `custom_table`: \n\n```\nview: events {\n sql_table_name: web_traffic.{{ _user_attributes['custom_event_table_name'] }} ;;\n\n dimension: event_id {\n type: number\n primary_key: yes\n sql: ${TABLE}.id ;;\n }\n}\n```"]]