Nutzerattribute für die dynamische Einschleusung von Schema- und Tabellennamen verwenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit der Funktion Nutzerattribute von Looker können Sie Schema- und/oder Tabellennamen dynamisch pro Nutzer einfügen.
Im ersten Schritt erstellen Sie ein Nutzerattribut, z. B. custom_schema oder custom_table, dem Sie jedem Nutzer einen Wert zuweisen. Sie können folgende Werte zuweisen:
Nachdem Sie das Nutzerattribut erstellt und den entsprechenden Wert für Ihre Nutzer zugewiesen haben, können Sie in der sql_table_name Ihrer Ansichtsdateien über Liquid-Variablen einen Verweis auf dieses Attribut hinzufügen.
Im Folgenden finden Sie zwei Beispiele, eines mit einem benutzerdefinierten Schema und eines mit einer benutzerdefinierten Tabelle.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-31 (UTC)."],[],[],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```"]]