Table 'test._t_tablename_new' doesn't exist
阿新 • • 發佈:2019-02-10
往表裡插入一條資料:
mysql> insert into t_message(MSG_ID) values('1');
ERROR 1146 (42S02): Table 'test._t_message' doesn't exist
提示的是_t_message不存在而不是t_message。_t_message感覺像是pt工具產生的。
檢視庫是存在t_message,但是_t_message確實不存在。
mysql> show tables;
+-----------------------+
| Tables_in_test |
+-----------------------+
| t |
| t_message |
+-----------------------+
7 rows in set (0.00 sec)
試著去建立一個跟t_message表結構相同的_t_message表:
mysql> create table _t_message like t_message;
Query OK, 0 rows affected (0.00 sec)
再次插入:
mysql> insert into t_message(MSG_ID) values('1');
Query OK, 1 row affected (0.00 sec)
插入成功! 檢視資料落到了 _t_message而不是t_message表。插入t_message反而是插入了_t_message表,是觸發器!!!
mysql> show TRIGGERS from test \G
*************************** 1. row ***************************
Trigger: pt_osc_test_t_message_ins
Event: INSERT
Table: t_message
***** ********************** 2. row ***************************
Trigger: pt_osc_test_t_message_upd
Event: UPDATE
Table: t_message
*************************** 3. row ***************************
Trigger: pt_osc_test_t_message_del
Event: DELETE
Table: t_message
3 rows in set (0.00 sec)
show TRIGGERS可以看到在t_message表上面有insert,update,delete三個觸發器。
把觸發器刪除就可以正常插入了:
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name
原因是:之前用pt-osc去改過表結構,中途錯誤退出,手動刪除了_t_message,但是觸發器沒有刪除,導致了插入報錯的這個問題。