- Categories:
Table functions (Object Modeling)
GET_ OBJECT_ REFERENCES¶
Returns a list of objects that a specified object references. Input is currently limited to the name of a view.
The following table identifies which types of database objects are currently returned in the output:
| Object Type | Returned in Output? |
|---|---|
| Tables | Yes |
| Views (including secure views) | Yes |
| Materialized views | No |
| Named stages (internal or external) | No |
| Streams | No |
| User-defined functions (UDF) / user-defined table functions (UDTF) | No |
Syntax¶
Arguments¶
DATABASE_NAME => 'string'Name of the database in which the schema and object reside.
SCHEMA_NAME => 'string'Name of the schema in which the object resides.
OBJECT_NAME => 'string'Name of the object. Currently limited to the name of a view (secure or not secure).
Returns¶
The function returns the following columns:
| Column Name | Data Type | Description |
|---|---|---|
| DATABASE_NAME | TEXT | Name of the database that contains the queried object. |
| SCHEMA_NAME | TEXT | Name of the schema that contains the queried object. |
| OBJECT_NAME | TEXT | Name of the queried object. |
| REFERENCED_DATABASE_NAME | TEXT | Name of the database containing an object that the queried object references. |
| REFERENCED_SCHEMA_NAME | TEXT | Name of the schema containing an object that the queried object references. |
| REFERENCED_OBJECT_NAME | TEXT | Name of an object that the queried object references. |
| REFERENCED_OBJECT_TYPE | TEXT | Type of object identified in the REFERENCED_OBJECT_NAME column. Values include TABLE or VIEW. |
Usage notes¶
-
This function requires the following privileges:
- SELECT on the view. To obtain references for a view, the role in use or a role granted to the role in use must have the SELECT privilege on the view. For details, refer to Table privileges and View privileges.
- OWNERSHIP on the secure view. If the dependency chain references any secure view, the role in use or a role granted to the role in use must have the OWNERSHIP privilege on the secure view. Otherwise, Snowflake returns this error message:
-
The
DATABASE_NAME,SCHEMA_NAME, andOBJECT_NAMEvalues must be enclosed in single quotes. Also, if any of these names contains any spaces, mixed-case characters, or special characters, the name must be double-quoted within the single quotes (e.g.'"My DB"'vs'mydb'). -
If the view references stages, UDFs, or materialized views, this function returns an error, rather than returning a list of referenced tables and views.
Examples¶
Return the list of references for a view: