English 中文(简体)
InnoDB: Changing the length of a VARCHAR main Key
原标题:InnoDB: Changing the length of a VARCHAR primary Key

我在InnoDB有一个表格,使用设在外凯的VARCHAR:

CREATE TABLE `portal_equity` (
   `isin` varchar(12) NOT NULL,
    ....,
    PRIMARY KEY (`isin`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 

另一表对表有外在限制:

CONSTRAINT `equity_id_refs_isin_2581bb1d` FOREIGN KEY (`equity_id`) REFERENCES `portal_equity` (`isin`)

我需要改变主要的VARCHAR栏的长度,因此我这样做。 现在,每当我想从“自由——平等”表中提一句话时,我就会发现以下正直错误,因为那一字的长度超过了原来的12年。

Foreign key constraint fails for table investtor.portal_equitypastvalue: CONSTRAINT equity_id_refs_isin_7eed44e7 FOREIGN KEY (equity_id) REFERENCES portal_equity (isin) Trying to add in child table, in index portal_equitypastvalue_equity_id_6e7526e1 tuple: DATA TUPLE: 3 fields; 0: len 12; hex 304c55303332333133343030; asc 0LU032313400;; 1: len 3; hex 8fb578; asc x;; 2: len 4; hex 8001398a; asc 9 ;;

But in parent table investtor.portal_equity, in index PRIMARY, the closest match we can find is record: PHYSICAL RECORD: n_fields 9; compact format; info bits 0 0: len 13; hex 304c5530333233313334303036; asc 0LU0323134006;; 1: len 6; hex 000000005139; asc Q9;; 2: len 7; hex 800000002d0110; asc - ;; 3: len 4; hex 61736466; asc asdf;; 4: len 4; hex 80000050; asc P;; 5: len 3; hex 736466; asc sdf;; 6: len 4; hex 80000001; asc ;; 7: len 2; hex 4144; asc AD;; 8: len 0; hex ; asc ;;

我是否需要重新提出所有外国关键制约因素? 这似乎相当过分。 这种行为/行为是否在其他地方有记载?

最佳回答

我是否需要重新提出所有外国关键制约因素?

是的。

That seems rather excessive.

如果你改变一个主要领域的数据类型,我自然认为,还需要改变外国关键领域的数据类型(及其各自的指数和制约因素)。

虽然documentation 国家 严格类型的长度不一定相同,逻辑意义决定,外国关键领域至少应当与你想要储存的任何数据一样。

亲爱!

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签