In Snowflake, I retrieve different views with the following SQL query:
SELECT * FROM "myDatabase"."mySchema"."VIEWS"
That returns a table with these columns notably:
TABLE_ID
TABLE_NAME
TABLE_SCHEMA_ID
TABLE_SCHEMA
TABLE_CATALOG_ID
TABLE_CATALOG
TABLE_OWNER
VIEW_DEFINITION
For each VIEW_DEFINITION
column entries, I am trying to extract all the strings <Schema_Name>.<View_Name>
(or at least the <Schema_Name>
).
Is it possible to do that with a SQL query (or by any other way)?
Edit
The table I obtain using the initial query is as follows:
TABLE_ID | TABLE_NAME | TABLE_SCHEMA_ID | TABLE_SCHEMA | TABLE_CATALOG_ID | TABLE_CATALOG | TABLE_OWNER | VIEW_DEFINITION |
---|---|---|---|---|---|---|---|
0001 | MY_TABLE_NAME | 99 | MY_TABLE_SCHEMA | 20 | PMY_TABLE_CATALOG | MY_OWNER_VIEWS_ADMIN | … |
where the VIEW_DEFINITION
column contains queries like the one below:
"CREATE OR REPLACE VIEW My_Table_Schema_VIEWS.My_Table_Name AS
WITH STUDY_SITE_SCOPE AS (
SELECT
...
FROM (
SELECT
A.SUBJECT_NUMBER
, A.SUBJECT_STATUS
FROM <Schema_Name>.<View_Name_1> X
JOIN <Schema_Name>.<View_Name_2> Y
...
)
JOIN (
SELECT
...
FROM <Schema_Name>.<View_Name_3> X
JOIN <Schema_Name>.<View_Name_4> Y
...
)
..."
From this VIEW_DEFINITION
I am trying to extract all the <Schema_Name>.<View_Name_XX>
strings (or at least the <Schema_Name>
).