> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-codes-1300-to-1399/e1356.md).

# Error 1356: View references invalid table(s) or column(s) or function(s) or definer/invoker of view

| Error Code | SQLSTATE | Error             | Description                                                                                                             |
| ---------- | -------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------- |
| 1356       | HY000    | ER\_VIEW\_INVALID | View '%s.%s' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |

## Possible Causes and Solutions

The view can't be used, because something it depends on is missing, or because its definer doesn't have the privileges it needs. For example:

* A table the view selects from was dropped or renamed.
* A column the view uses was dropped or renamed.
* A stored function the view calls was dropped.
* The view's definer, or the invoker for a view with `SQL SECURITY INVOKER`, lost a privilege on a table the view uses.

```
ALTER TABLE vb DROP COLUMN b;
SELECT * FROM v_col;
ERROR 1356 (HY000): View 'shop.v_col' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
```

The message doesn't say which of these is the problem. To find out, run [SHOW WARNINGS](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-warnings.md) right after the error, or [CHECK TABLE](/docs/server/reference/sql-statements/table-statements/check-table.md) on the view. Both can show the underlying error:

```
CHECK TABLE v_tab;
+------------+-------+----------+------------------------------------------------------------------------------------------------------------------------------+
| Table      | Op    | Msg_type | Msg_text                                                                                                                     |
+------------+-------+----------+------------------------------------------------------------------------------------------------------------------------------+
| shop.v_tab | check | Error    | Table 'shop.vb' doesn't exist                                                                                                |
| shop.v_tab | check | Error    | View 'shop.v_tab' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them |
| shop.v_tab | check | error    | Corrupt                                                                                                                      |
+------------+-------+----------+------------------------------------------------------------------------------------------------------------------------------+
```

`Corrupt` here means only that the view is invalid. The view definition itself is fine, and [SHOW CREATE VIEW](/docs/server/reference/sql-statements/administrative-sql-statements/show/show-create-view.md) still shows it.

To solve the error:

* Re-create the missing table, column or function, or change the view to match the new names with [CREATE OR REPLACE VIEW](/docs/server/server-usage/views/create-view.md) or [ALTER VIEW](/docs/server/server-usage/views/alter-view.md).
* Grant the missing privileges to the view's definer, which `SHOW CREATE VIEW` shows. For an `SQL SECURITY INVOKER` view, grant them to the account that uses the view.
* Remove a view that's no longer needed with [DROP VIEW](/docs/server/server-usage/views/drop-view.md).

A view whose definer account doesn't exist gives [error 1446](/docs/server/reference/error-codes/mariadb-error-codes-1400-to-1499/e1446.md) instead (`The user specified as a definer ('gone'@'localhost') does not exist`). Creating such a view succeeds, with a note that has the same text.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

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