GET_VIEW_DDL
GET_VIEW_DDL(<view name>)
is a function that shows the CREATE VIEW statement for a view.
Tip
For tables, see GET_DDL.
For the entire database, see DUMP_DATABASE_DDL.
For UDFs, see GET_FUNCTION_DDL.
Permissions
The role must have the CONNECT
permission at the database level.
Syntax
get_view_ddl_statement ::=
SELECT GET_VIEW_DDL('[schema_name.]view_name')
;
schema_name ::= identifier
view_name ::= identifier
Parameters
Parameter |
Description |
---|---|
|
The name of the schema. |
|
The name of the view. |
Examples
Getting the DDL for a view
The result of the GET_VIEW_DDL
function is a verbose version of the CREATE VIEW statement, which may include additional information that was added by SQream DB. For example, schemas and column names will be be specified explicitly.
farm=> CREATE VIEW angry_animals AS SELECT * FROM cool_animals WHERE is_agressive = false;
executed
farm=> SELECT GET_VIEW_DDL('angry_animals');
create view "public".angry_animals as
select
"cool_animals"."id" as "id",
"cool_animals"."name" as "name",
"cool_animals"."weight" as "weight",
"cool_animals"."is_agressive" as "is_agressive"
from
"public".cool_animals as cool_animals
where
"cool_animals"."is_agressive" = false;
Exporting view DDL to a file
COPY (SELECT GET_VIEW_DDL('angry_animals')) TO '/home/rhendricks/angry_animals.sql';