Common SQL Errors

MySQL Error 1347: ER_WRONG_OBJECT – How to Diagnose and Fix

Galaxy Team
August 6, 2025

Error 1347 indicates you are trying to perform an operation on the wrong kind of database object, such as calling DROP VIEW on a table.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1347?

MySQL Error 1347: ER_WRONG_OBJECT occurs when the object you reference is not the expected type for the command (for example, issuing ALTER TABLE on a view). Verify the object’s type with SHOW FULL TABLES, then rerun the correct statement on the proper object or recreate the object with the right type.

Error Highlights

Typical Error Message

%s.%s' is not %s

Error Type

Object Type Error

Language

MySQL

Symbol

ER_WRONG_OBJECT

Error Code

1347

SQL State

HY000

Explanation

Table of Contents

What does MySQL error 1347 mean?

Error 1347 (ER_WRONG_OBJECT) fires when MySQL detects a mismatch between the SQL statement and the referenced object type. The server expects the object to be a table, view, trigger, or routine that matches the command. If the type differs, execution stops and returns the message “db_name.obj_name is not object_type”.

The error protects metadata integrity. Dropping or altering the wrong kind of object could corrupt schemas or break dependencies, so MySQL blocks the operation immediately.

When does this error appear?

Developers encounter error 1347 while running DDL commands like ALTER TABLE, DROP VIEW, or TRUNCATE TABLE on an object that was created as another type. The problem also shows up in stored procedures that reference outdated object definitions after schema refactoring.

It is version agnostic and can occur in MySQL 5.7, 8.0, Amazon RDS, Google Cloud SQL, and MariaDB forks.

Why is it critical to resolve quickly?

Leaving the error unresolved blocks deployment pipelines and automated migrations. Continuous integration jobs fail, and data teams lose productivity. Fixing it ensures DDL scripts run cleanly, backups restore, and applications relying on correct object types remain reliable.

Common Causes

Using the wrong DDL keyword

Issuing DROP VIEW against a base table or DROP TABLE against a view immediately triggers error 1347.

Object recreated as a new type

A table dropped and later recreated as a view keeps the same name but different type, confusing legacy scripts.

Stale cached metadata in code

Long-running applications store the original object type and call outdated DDL.

Typographical mistakes

Developers sometimes mis-type object names, referencing a similarly named view rather than the intended table.

Incorrect migration ordering

Schema change tools may attempt to alter a table before the view with the same name is dropped, causing a type mismatch.

Related Errors

Error 1051: Unknown table

Occurs when the object does not exist at all, unlike 1347 which exists but with the wrong type.

Error 1146: Table doesn't exist

Similar to 1051 but arises during SELECT/INSERT operations rather than DDL.

Error 1049: Unknown database

Raised when the specified database does not exist. Verify db_name before checking object type.

MariaDB error ER_VIEW_NO_EXPLAIN

Happens when attempting to EXPLAIN a view without underlying access, conceptually different yet also view related.

FAQs

How do I check if a name is a table or a view?

Run SHOW FULL TABLES or query INFORMATION_SCHEMA.TABLES where TABLE_TYPE indicates BASE TABLE or VIEW.

Can I safely change a view into a table?

You must DROP the view first, then CREATE TABLE with the same name. Backup data before dropping to avoid loss.

Why does TRUNCATE TABLE fail with error 1347?

TRUNCATE works only on BASE TABLE objects. If the name points to a view, MySQL returns ER_WRONG_OBJECT.

Does Galaxy prevent this error automatically?

Galaxy highlights object types in the schema browser and warns when a DDL command mismatches the type, reducing the chance of ER_WRONG_OBJECT.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo