Skip to content

Commit 34cd086

Browse files
committed
remove unnecessary stuff
1 parent 3b61891 commit 34cd086

File tree

1 file changed

+2
-155
lines changed

1 file changed

+2
-155
lines changed

src/content/docs/snowflake/features/metadata-views.md

Lines changed: 2 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ tags: ["Base"]
88

99
Snowflake provides metadata views and table functions to query information about database objects, schemas, tables, columns, and query history. These views are available through two schemas:
1010

11-
- **INFORMATION_SCHEMA** — a read-only schema present in every Snowflake database, scoped to that database's objects.
12-
- **ACCOUNT_USAGE** — available in the special `SNOWFLAKE` database, providing account-wide views that span all databases.
11+
- **INFORMATION_SCHEMA**: A read-only schema present in every Snowflake database, scoped to that database's objects.
12+
- **ACCOUNT_USAGE**: Available in the special `SNOWFLAKE` database, providing account-wide views that span all databases.
1313

1414
The Snowflake emulator supports querying metadata views, allowing you to inspect the structure of your local Snowflake objects using the same SQL syntax as the Snowflake service.
1515

@@ -21,23 +21,6 @@ The `INFORMATION_SCHEMA` schema contains views that return metadata about object
2121

2222
The `TABLES` view returns metadata about tables and views in the current database.
2323

24-
```sql
25-
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ROW_COUNT
26-
FROM INFORMATION_SCHEMA.TABLES
27-
WHERE TABLE_SCHEMA = 'PUBLIC';
28-
```
29-
30-
The expected output is:
31-
32-
```bash title="Output"
33-
+-----------------+--------------+--------------+------------+-----------+
34-
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ROW_COUNT |
35-
|-----------------+--------------+--------------+------------+-----------|
36-
| MY_DATABASE | PUBLIC | ORDERS | BASE TABLE | 0 |
37-
| MY_DATABASE | PUBLIC | CUSTOMERS | BASE TABLE | 0 |
38-
+-----------------+--------------+--------------+------------+-----------+
39-
```
40-
4124
The following columns are returned:
4225

4326
| Column | Data Type | Description |
@@ -76,24 +59,6 @@ The following columns are returned:
7659

7760
The `COLUMNS` view returns metadata about the columns of tables and views in the current database.
7861

79-
```sql
80-
SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, ORDINAL_POSITION
81-
FROM INFORMATION_SCHEMA.COLUMNS
82-
WHERE TABLE_SCHEMA = 'PUBLIC' AND TABLE_NAME = 'ORDERS';
83-
```
84-
85-
The expected output is:
86-
87-
```bash title="Output"
88-
+------------+-------------+-----------+-------------+------------------+
89-
| TABLE_NAME | COLUMN_NAME | DATA_TYPE | IS_NULLABLE | ORDINAL_POSITION |
90-
|------------+-------------+-----------+-------------+------------------|
91-
| ORDERS | ORDER_ID | NUMBER | NO | 1 |
92-
| ORDERS | CUSTOMER_ID | NUMBER | YES | 2 |
93-
| ORDERS | ORDER_DATE | DATE | YES | 3 |
94-
+------------+-------------+-----------+-------------+------------------+
95-
```
96-
9762
The following columns are returned:
9863

9964
| Column | Data Type | Description |
@@ -147,22 +112,6 @@ The following columns are returned:
147112

148113
The `SCHEMATA` view returns metadata about schemas in the current database.
149114

150-
```sql
151-
SELECT CATALOG_NAME, SCHEMA_NAME, SCHEMA_OWNER, CREATED
152-
FROM INFORMATION_SCHEMA.SCHEMATA;
153-
```
154-
155-
The expected output is:
156-
157-
```bash title="Output"
158-
+----------------+--------------------+--------------+-------------------------------+
159-
| CATALOG_NAME | SCHEMA_NAME | SCHEMA_OWNER | CREATED |
160-
|----------------+--------------------+--------------+-------------------------------|
161-
| MY_DATABASE | PUBLIC | PUBLIC | 2024-01-01 00:00:00.000000+00 |
162-
| MY_DATABASE | INFORMATION_SCHEMA | NULL | 2024-01-01 00:00:00.000000+00 |
163-
+----------------+--------------------+--------------+-------------------------------+
164-
```
165-
166115
The following columns are returned:
167116

168117
| Column | Data Type | Description |
@@ -187,22 +136,6 @@ The following columns are returned:
187136

188137
The `VIEWS` view returns metadata about views in the current database.
189138

190-
```sql
191-
SELECT TABLE_SCHEMA, TABLE_NAME, VIEW_DEFINITION, IS_SECURE
192-
FROM INFORMATION_SCHEMA.VIEWS
193-
WHERE TABLE_SCHEMA = 'PUBLIC';
194-
```
195-
196-
The expected output is:
197-
198-
```bash title="Output"
199-
+--------------+------------------+--------------------------------------------------------+-----------+
200-
| TABLE_SCHEMA | TABLE_NAME | VIEW_DEFINITION | IS_SECURE |
201-
|--------------+------------------+--------------------------------------------------------+-----------|
202-
| PUBLIC | ACTIVE_ORDERS_V | CREATE VIEW PUBLIC.ACTIVE_ORDERS_V AS SELECT * FROM .. | NO |
203-
+--------------+------------------+--------------------------------------------------------+-----------+
204-
```
205-
206139
The following columns are returned:
207140

208141
| Column | Data Type | Description |
@@ -226,21 +159,6 @@ The following columns are returned:
226159

227160
The `DATABASES` view returns metadata about databases accessible in the account.
228161

229-
```sql
230-
SELECT DATABASE_NAME, DATABASE_OWNER, TYPE, CREATED
231-
FROM INFORMATION_SCHEMA.DATABASES;
232-
```
233-
234-
The expected output is:
235-
236-
```bash title="Output"
237-
+---------------+----------------+----------+-------------------------------+
238-
| DATABASE_NAME | DATABASE_OWNER | TYPE | CREATED |
239-
|---------------+----------------+----------+-------------------------------|
240-
| MY_DATABASE | PUBLIC | STANDARD | 2024-01-01 00:00:00.000000+00 |
241-
+---------------+----------------+----------+-------------------------------+
242-
```
243-
244162
The following columns are returned:
245163

246164
| Column | Data Type | Description |
@@ -264,24 +182,6 @@ In addition to views, `INFORMATION_SCHEMA` provides table functions that return
264182

265183
The `QUERY_HISTORY` table function returns the recent query execution history for the current account.
266184

267-
```sql
268-
SELECT QUERY_ID, QUERY_TEXT, USER_NAME, EXECUTION_STATUS, START_TIME, END_TIME
269-
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY(
270-
RESULT_LIMIT => 10
271-
));
272-
```
273-
274-
The expected output is:
275-
276-
```bash title="Output"
277-
+------------------+-----------------------------+-----------+------------------+-------------------------------+-------------------------------+
278-
| QUERY_ID | QUERY_TEXT | USER_NAME | EXECUTION_STATUS | START_TIME | END_TIME |
279-
|------------------+-----------------------------+-----------+------------------+-------------------------------+-------------------------------|
280-
| 01b8c8f4-0001-.. | SELECT * FROM ORDERS | ROOT | SUCCESS | 2024-01-01 12:00:01.000000+00 | 2024-01-01 12:00:02.000000+00 |
281-
| 01b8c8f4-0002-.. | CREATE TABLE ORDERS (...) | ROOT | SUCCESS | 2024-01-01 12:00:00.000000+00 | 2024-01-01 12:00:01.000000+00 |
282-
+------------------+-----------------------------+-----------+------------------+-------------------------------+-------------------------------+
283-
```
284-
285185
The function accepts the following parameters:
286186

287187
| Parameter | Type | Default | Description |
@@ -299,24 +199,6 @@ The `END_TIME_RANGE_START` and `END_TIME_RANGE_END` parameters are accepted but
299199

300200
The `QUERY_HISTORY_BY_USER` table function returns the recent query execution history for a specific user. It returns the same columns as `QUERY_HISTORY`.
301201

302-
```sql
303-
SELECT QUERY_ID, QUERY_TEXT, EXECUTION_STATUS, START_TIME
304-
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY_BY_USER(
305-
USER_NAME => 'ROOT',
306-
RESULT_LIMIT => 10
307-
));
308-
```
309-
310-
The expected output is:
311-
312-
```bash title="Output"
313-
+------------------+-----------------------------+------------------+-------------------------------+
314-
| QUERY_ID | QUERY_TEXT | EXECUTION_STATUS | START_TIME |
315-
|------------------+-----------------------------+------------------+-------------------------------|
316-
| 01b8c8f4-0001-.. | SELECT * FROM ORDERS | SUCCESS | 2024-01-01 12:00:01.000000+00 |
317-
+------------------+-----------------------------+------------------+-------------------------------+
318-
```
319-
320202
The function accepts the following parameters:
321203

322204
| Parameter | Type | Default | Description |
@@ -331,24 +213,6 @@ The function accepts the following parameters:
331213

332214
The `TAG_REFERENCES` table function returns all tag assignments for a specific object within the current database.
333215

334-
```sql
335-
SELECT TAG_DATABASE, TAG_SCHEMA, TAG_NAME, TAG_VALUE, OBJECT_NAME, DOMAIN, COLUMN_NAME
336-
FROM TABLE(INFORMATION_SCHEMA.TAG_REFERENCES(
337-
'MY_TABLE',
338-
'table'
339-
));
340-
```
341-
342-
The expected output is:
343-
344-
```bash title="Output"
345-
+--------------+------------+-------------+-----------+-------------+--------+-------------+
346-
| TAG_DATABASE | TAG_SCHEMA | TAG_NAME | TAG_VALUE | OBJECT_NAME | DOMAIN | COLUMN_NAME |
347-
|--------------+------------+-------------+-----------+-------------+--------+-------------|
348-
| MY_DATABASE | PUBLIC | COST_CENTER | finance | MY_TABLE | TABLE | NULL |
349-
+--------------+------------+-------------+-----------+-------------+--------+-------------+
350-
```
351-
352216
The function accepts the following positional parameters:
353217

354218
| Parameter | Type | Description |
@@ -364,23 +228,6 @@ The `ACCOUNT_USAGE` schema is available in the special `SNOWFLAKE` database and
364228

365229
The `ACCOUNT_USAGE.TAG_REFERENCES` view returns all tag-to-object associations across the entire account. Unlike the `INFORMATION_SCHEMA.TAG_REFERENCES()` table function, this view returns every tag assignment without requiring you to specify a particular object.
366230

367-
```sql
368-
SELECT TAG_DATABASE, TAG_SCHEMA, TAG_NAME, TAG_VALUE, OBJECT_DATABASE, OBJECT_NAME, DOMAIN
369-
FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
370-
WHERE DOMAIN = 'TABLE';
371-
```
372-
373-
The expected output is:
374-
375-
```bash title="Output"
376-
+--------------+------------+-------------+-----------+-----------------+-------------+--------+
377-
| TAG_DATABASE | TAG_SCHEMA | TAG_NAME | TAG_VALUE | OBJECT_DATABASE | OBJECT_NAME | DOMAIN |
378-
|--------------+------------+-------------+-----------+-----------------+-------------+--------|
379-
| MY_DATABASE | PUBLIC | COST_CENTER | finance | MY_DATABASE | MY_TABLE | TABLE |
380-
| MY_DATABASE | PUBLIC | SENSITIVITY | high | MY_DATABASE | MY_TABLE | TABLE |
381-
+--------------+------------+-------------+-----------+-----------------+-------------+--------+
382-
```
383-
384231
The following columns are returned:
385232

386233
| Column | Data Type | Description |

0 commit comments

Comments
 (0)