Updated on 2024-05-29 GMT+08:00

SHOW VIEWS

Syntax

SHOW VIEWS [IN/FROM database_name] [ LIKE pattern [ESCAPE escapeChar] ]

Description

This statement is used to list all views that meet the conditions in a specified schema.

By default, the current schema is used. You can also use the in/from clause to specify a schema.

The LIKE clause is used to filter views whose names meet the regular expression. If this clause is not used, all views are listed. The matched views are sorted in alphabetic order.

Currently, the regular expression supports only the asterisk (*) (matching any character).

Example

Create views:

Create schema test1;
Use test1;
Create table t1(id int, name string);
Create view v1 as select * from t1;
Create view v2 as select * from t1;
Create view t1view as select * from t1;
Create view t2view as select * from t1;
 
Show views;
Table
--------
 t1view
 t2view
 v1
 v2
(4 rows)
 
Show views like 'v1';
 Table
-------
 v1
(1 row)
 
Show views 'v_';
Table 
-------
 v1    
 v2    
(2 rows)
show views like 't*';
 Table
--------
 t1view
 t2view
 
Show views in test1;
 Table
--------
 t1view
 t2view
 v1
 v2
(4 rows)