我有一个名为 status 的表,例如:
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| db_table | varchar(255) | NO | | | |
| name | varchar(255) | NO | | | |
| rank | varchar(6) | YES | | NULL | |
| style_id | int(11) unsigned | NO | | NULL | |
+----------+------------------+------+-----+---------+----------------+
带有创建语句
CREATE TABLE `status` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`db_table` varchar(255) NOT NULL DEFAULT '',
`name` varchar(255) NOT NULL DEFAULT '',
`rank` varchar(6) DEFAULT NULL,
`style_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8
luqibase generateChangelog 命令
liquibase --url=jdbc:mysql://localhost/testdb generateChangeLog
输出
Liquibase generateChangeLog Failed: Error executing SQL select CONSTRAINT_NAME from information_schema.table_constraints where constraint_schema='testdb' and constraint_type='UNIQUE' and table_name='status': Unknown table 'status' in information_schema
我不知道为什么这是一个问题,为了增加更多的谜题,我从 mysql 得到这个响应
select *
from information_schema.table_constraints
where constraint_schema='testdb'
and table_name='status';
错误 1109 (42S02): information_schema 中的未知表“状态”
虽然,我看到它没有table_name='status'
列出状态
mysql 和/或 liquibase 有什么问题?“状态”是一些保留的东西或我们不能用作表名的特殊用途。
相同的架构适用于较旧的 liquibase 版本 2.0.5 :(
编辑
这个问题与表名有关status
案例A
drop table status;
create table statusx
(
id int(11) unsigned auto_increment,
name varchar(20) ,
primary key (`id`)
);
liquibase --url=jdbc:mysql://localhost/testdb generateChangeLog
工作正常
案例b
drop table statusx;
create table status
(
id int(11) unsigned auto_increment,
name varchar(20),
primary key (`id`)
);
liquibase --url=jdbc:mysql://localhost/testdb generateChangeLog
同样的错误:
Liquibase generateChangeLog Failed: Error execution SQL select CONSTRAINT_NAME from information_schema.table_constraints where constraint_schema='testdb' and constraint_type='UNIQUE' and table_name='status': Unknown table 'status' in information_schema
直接查询也失败:
select *
from information_schema.table_constraints
where constraint_schema = 'testdb'
and table_name='status';
虽然这有效:
select *
from information_schema.table_constraints
where constraint_schema='testdb'
and table_name='statusx';
作品
select *
from information_schema.table_constraints
where constraint_schema='ufg_a'
and table_name='`status`';
我认为 liquibase 的解决方法是在表名周围使用反引号,例如 table_name=' status
'
mysql有些奇怪,我希望status不是mysql中的保留字