# SHOW CREATE VIEW

## Syntax

```sql
SHOW CREATE VIEW [view-name]
```

## Description

This statement shows a [CREATE VIEW](/docs/server/server-usage/views/create-view.md) statement that creates the given [view](/docs/server/server-usage/views.md), as well as the character set used by the connection when the view was created. This statement also works with views.

`SHOW CREATE VIEW` quotes table, column and stored function names according to the value of the [sql\_quote\_show\_create](/docs/server/server-management/variables-and-modes/server-system-variables.md#sql_quote_show_create) server system variable.

## Examples

```sql
SHOW CREATE VIEW example\G
*************************** 1. row ***************************
                View: example
         Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL
SECURITY DEFINER VIEW `example` AS (select `t`.`id` AS `id`,`t`.`s` AS `s` from
`t`)
character_set_client: cp850
collation_connection: cp850_general_ci
```

With [sql\_quote\_show\_create](/docs/server/server-management/variables-and-modes/server-system-variables.md#sql_quote_show_create) off:

```sql
SHOW CREATE VIEW example\G
*************************** 1. row ***************************
                View: example
         Create View: CREATE ALGORITHM=UNDEFINED DEFINER=root@localhost SQL SECU
RITY DEFINER VIEW example AS (select t.id AS id,t.s AS s from t)
character_set_client: cp850
collation_connection: cp850_general_ci
```

## Grants

To be able to see a view, you need to have the [SHOW VIEW](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#table-privileges) and the [SELECT](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#table-privileges) privilege on the view:

```sql
GRANT SHOW VIEW,SELECT ON test_database.test_view TO 'test'@'localhost';
```

## See Also

* [Grant privileges to tables, views etc](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-create-view.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
