ERROR 1356 (HY000): View 'db_name.view_name' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them is raised when a view definition refers to an object — a table, column, or function — that no longer exists or is no longer accessible. The error symbol is ER_VIEW_INVALID.
Impact
Queries against the affected view fail immediately with this error. Because views can be created and left in place for a long time, this error often surfaces unexpectedly: a routine SELECT against a view that worked fine yesterday starts failing after a schema migration drops or renames a table, adds or removes a column, or changes a stored function. Applications that treat views as stable API endpoints are particularly exposed — a silent schema change downstream breaks the view without any warning at creation time.
In ORMs such as SQLAlchemy, ActiveRecord, or Hibernate, the error propagates as a database exception wrapped in a generic query-execution error. The view name is usually present in the message, but the specific invalid object is not always spelled out, making it necessary to inspect the view definition manually.
Common Causes
A table referenced by the view was dropped or renamed.
CREATE VIEWstores the definition as text; MySQL does not track dependencies. Ifordersis renamed toorders_v2or dropped, any view built onordersbecomes invalid immediately.A column referenced by the view was dropped or renamed. If a view selects specific columns (
SELECT user_id, email FROM users) andemailis later dropped or renamed, the view breaks at query time rather than atALTER TABLEtime.A stored function referenced in the view was dropped or renamed. Views can embed function calls. Dropping the function invalidates every view that uses it.
The view definer's account has been removed or has lost privileges. By default, views run with
SQL SECURITY DEFINERsemantics. If the account named in theDEFINERclause is dropped or has its privileges revoked, MySQL raises 1356 even when the underlying tables are intact.The view was migrated to a different database or server where the referenced tables do not exist under the same name or schema.
Troubleshooting and Resolution Steps
Identify what the view references.
SELECT VIEW_DEFINITION FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'your_db' AND TABLE_NAME = 'your_view';Read the definition and note every table, column, and function name.
Check whether the referenced tables exist.
SHOW TABLES LIKE 'orders'; -- or SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'your_db' AND TABLE_NAME IN ('orders', 'customers');If a table is missing, either recreate it, restore it from a backup, or rewrite the view to point at its new name.
Verify that the referenced columns exist.
SHOW COLUMNS FROM orders; -- or SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'your_db' AND TABLE_NAME = 'orders';If a column was renamed, update the view definition to use the new column name.
Recreate or rewrite the view once the issue is identified.
CREATE OR REPLACE VIEW order_summary AS SELECT o.id, o.created_at, c.name AS customer_name FROM orders_v2 o -- updated table name JOIN customers c ON c.id = o.customer_id;Using
CREATE OR REPLACE VIEWreplaces the definition in-place without needing to drop the view first.Check the view definer if the underlying tables look correct.
SELECT DEFINER, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'your_db' AND TABLE_NAME = 'your_view';If the definer account no longer exists or lacks the necessary privileges, recreate the view under a valid account:
-- Drop and recreate with the current user as definer DROP VIEW IF EXISTS your_view; CREATE DEFINER = CURRENT_USER VIEW your_view AS SELECT ...;Alternatively, switch the view to
SQL SECURITY INVOKERso it runs with the calling user's privileges instead:ALTER VIEW your_view SQL SECURITY INVOKER AS SELECT ...;Use
CHECK TABLEto expose the error proactively in scripts.CHECK TABLE your_view;This reports whether the view is valid without executing a full query against it, which is useful for health-check scripts.
Additional Information
- MySQL validates view references at query execution time, not at view creation time. This means
CREATE VIEWsucceeds even when the referenced table does not exist, and the error only surfaces when the view is queried. - Error 1356 covers several distinct root causes (missing table, missing column, missing function, privilege loss) — all described in the single generic message. Checking
SHOW WARNINGSimmediately after the failed query sometimes provides a more specific hint. - Related error codes: 1146 (
ER_NO_SUCH_TABLE) and 1054 (ER_BAD_FIELD_ERROR) appear when querying tables directly; 1356 is the view-level counterpart. - In replication setups, view definitions replicate but the underlying tables must exist identically on the replica. A replica lagging behind a table rename or drop will raise 1356 on the replica before it processes the DDL event.
information_schema.VIEW_TABLE_USAGE(available in MySQL 8.0.13+) lists tables and views that a given view depends on, providing a cleaner dependency map than manually parsingVIEW_DEFINITION.
Frequently Asked Questions
Why did CREATE VIEW succeed if the table didn't exist?
MySQL does not validate the referenced objects when a view is created. The definition is stored as-is. This is intentional — it allows views to be created before their underlying tables are populated — but it also means silent staleness. A subsequent schema change will not invalidate the stored definition, so the breakage only surfaces at query time.
Can I prevent this from happening during a schema migration?
Yes. Before dropping or renaming a table or column, query information_schema.VIEW_DEFINITION or information_schema.VIEW_TABLE_USAGE (MySQL 8.0.13+) to find all views that reference the object. Update or drop those views as part of the migration, then make the schema change. Some migration tools (Flyway, Liquibase) can automate this sequencing.
Why does the error say "definer/invoker of view lack rights" even though the table exists?
When a view is created with SQL SECURITY DEFINER (the default), MySQL checks whether the definer account has SELECT privilege on the underlying tables — not the account running the query. If the definer account was dropped or had its grants revoked, MySQL raises 1356 regardless of the calling user's privileges. Fix by reassigning the definer or switching to SQL SECURITY INVOKER.
Does SHOW CREATE VIEW still work when the view is invalid?
Yes. SHOW CREATE VIEW your_view returns the stored CREATE VIEW statement even when the view is broken, because it reads the metadata rather than executing the view. This is the safest way to inspect the definition of an invalid view.