This topic describes how to handle ERROR 1146, where a queried table does not exist in the MySQL mode of OceanBase Database.
Symptom
When you query the student table, this error is returned, indicating that the table does not exist.
obclient> desc student;
ERROR 1146 (42S02): Table 'test.student' doesn't exist
The error codes corresponding to this error message are as follows:
Error code: ERROR 1146
Error code in OceanBase Database: 5019
Error code compatible with MySQL Database: 1146
For more information about the error codes, see Overview of error messages.
Possible causes
If the target table does not exist, the system returns an error.
Troubleshooting procedure
Take the following steps to check whether a table exists and create the table if it does not exist.
Check whether the table exists in the database. For example:
obclient> SHOW TABLES; +----------------+ | Tables_in_test | +----------------+ | ordr | +----------------+ 1 row in setIf the table does not exist, execute the
CREATE TABLEstatement to create the table. Here is an example:CREATE TABLE student( id int, name varchar(18), sex char(1), age int, address varchar(200), email varchar(100), date date, PRIMARY KEY (id) );Query the table again.
obclient> desc student; +---------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | name | varchar(18) | YES | | NULL | | | sex | char(1) | YES | | NULL | | | age | int(11) | YES | | NULL | | | address | varchar(200) | YES | | NULL | | | email | varchar(100) | YES | | NULL | | | date | date | YES | | NULL | | +---------+--------------+------+-----+---------+-------+ 7 rows in set