|
| 1 | +--- |
| 2 | +layout: global |
| 3 | +title: SHOW CACHED TABLES |
| 4 | +displayTitle: SHOW CACHED TABLES |
| 5 | +license: | |
| 6 | + Licensed to the Apache Software Foundation (ASF) under one or more |
| 7 | + contributor license agreements. See the NOTICE file distributed with |
| 8 | + this work for additional information regarding copyright ownership. |
| 9 | + The ASF licenses this file to You under the Apache License, Version 2.0 |
| 10 | + (the "License"); you may not use this file except in compliance with |
| 11 | + the License. You may obtain a copy of the License at |
| 12 | +
|
| 13 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +
|
| 15 | + Unless required by applicable law or agreed to in writing, software |
| 16 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | + See the License for the specific language governing permissions and |
| 19 | + limitations under the License. |
| 20 | +--- |
| 21 | + |
| 22 | +### Description |
| 23 | + |
| 24 | +The `SHOW CACHED TABLES` statement returns every in-memory cache entry that was registered with an explicit table or view name, for example via [`CACHE TABLE`](sql-ref-syntax-aux-cache-cache-table.html) or `spark.catalog.cacheTable`. The result has two columns: `tableName` (the name used when caching) and `storageLevel` (a string description of how the data is cached). |
| 25 | + |
| 26 | +Relations cached only through `Dataset.cache()` / `DataFrame.cache()` without assigning a catalog name are **not** listed. |
| 27 | + |
| 28 | +### Syntax |
| 29 | + |
| 30 | +```sql |
| 31 | +SHOW CACHED TABLES |
| 32 | +``` |
| 33 | + |
| 34 | +### Examples |
| 35 | + |
| 36 | +```sql |
| 37 | +CACHE TABLE my_table AS SELECT * FROM src; |
| 38 | + |
| 39 | +SHOW CACHED TABLES; |
| 40 | ++----------+------------------+ |
| 41 | +| tableName| storageLevel| |
| 42 | ++----------+------------------+ |
| 43 | +| my_table| MEMORY_AND_DISK| |
| 44 | ++----------+------------------+ |
| 45 | +``` |
| 46 | + |
| 47 | +### Related Statements |
| 48 | + |
| 49 | +* [CACHE TABLE](sql-ref-syntax-aux-cache-cache-table.html) |
| 50 | +* [UNCACHE TABLE](sql-ref-syntax-aux-cache-uncache-table.html) |
| 51 | +* [CLEAR CACHE](sql-ref-syntax-aux-cache-clear-cache.html) |
0 commit comments