外键约束仍然存在

时间:2020-03-05 00:01:53

标签: mysql phpmyadmin mariadb

MariaDB,myphpadmin

由于创建FK约束的问题,我删除了一个表。我正在尝试重新创建表,但似乎FK约束仍然在DB的某个位置。我无法删除,因为我没有看到任何引用。我不知道去哪里放约束

尝试创建表时出现以下错误。

=====================================
2020-03-04 18:58:15 0x14c6100cc700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 40 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 82 srv_active, 0 srv_shutdown, 53679 srv_idle
srv_master_thread log flush and writes: 53761
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 467
OS WAIT ARRAY INFO: signal count 372
RW-shared spins 0, rounds 1085, OS waits 396
RW-excl spins 0, rounds 4555, OS waits 20
RW-sx spins 3, rounds 34, OS waits 1
Spin rounds per wait: 1085.00 RW-shared, 4555.00 RW-excl, 11.33 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2020-03-04 18:58:14 0x14c610081700 Error in foreign key constraint of table moviesdb/movie_genre:
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table
or one of the ON ... SET NULL columns is declared NOT NULL. Constraint:
,
  CONSTRAINT `genre_id_fk` FOREIGN KEY (`genre_id`) REFERENCES `genre` (`genre_id`) ON DELETE CASCADE ON UPDATE CASCADE
------------
TRANSACTIONS
------------
Trx id counter 237460
Purge done for trx's n:o < 237460 undo n:o < 0 state: running
History list length 1
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 304315944137048, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 304315944132792, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
5389 OS file reads, 3086 OS file writes, 1050 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.55 writes/s, 0.20 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 1 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
Hash table size 69257, node heap has 3 buffer(s)
Hash table size 69257, node heap has 2 buffer(s)
0.07 hash searches/s, 1.10 non-hash searches/s
---
LOG
---
Log sequence number 845237404
Log flushed up to   845237404
Pages flushed up to 845237404
Last checkpoint at  845237395
0 pending log flushes, 0 pending chkp writes
673 log i/o's done, 0.10 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 285212672
Dictionary memory allocated 847024
Buffer pool size   16030
Free buffers       10583
Database pages     5432
Old database pages 2018
Modified db pages  0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 5071, created 361, written 2302
0.00 reads/s, 0.10 creates/s, 0.40 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 5432, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=488, Main thread ID=22840912578304, state: sleeping
Number of rows inserted 820, updated 2, deleted 4, read 134187
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 个答案:

答案 0 :(得分:1)

错误消息就在日志中:

Error in foreign key constraint of table moviesdb/movie_genre
there is no index in the table which would contain
the columns as the first columns, or the data types in the
table do not match the ones in the referenced table

所以基本上这意味着

  • genre_id中列movie_genre的数据类型和长度与表genre_id中列genre的列

  • 或:genregenre_id)上没有索引(或genre_id首先出现在其中);如果是这样,则表明您的表结构存在另一个缺陷,因为很有可能genre_id应该是genre表的主键。