日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > 數(shù)據(jù)庫(kù) > MySql > mysql提示used in key specification without a key length

mysql提示used in key specification without a key length

來(lái)源:程序員人生   發(fā)布時(shí)間:2014-03-03 05:24:20 閱讀次數(shù):6545次

今天最火軟件站小編在寫(xiě)一個(gè)PHP小東西的時(shí)候遇到了一個(gè)問(wèn)題,設(shè)計(jì)數(shù)據(jù)庫(kù)類(lèi)型的時(shí)候提示:xxxx used in key specification without a key length,百思不得其解,后來(lái)在網(wǎng)上找到關(guān)于這個(gè)問(wèn)題的答案。

原來(lái)Mysql數(shù)據(jù)庫(kù)對(duì)于BLOB/TEXT這樣類(lèi)型的數(shù)據(jù)結(jié)構(gòu)只能索引前N個(gè)字符。所以這樣的數(shù)據(jù)類(lèi)型不能作為主鍵,也不能是UNIQUE的。所以要換成VARCH,但是VARCHAR類(lèi)型的大小也不能大于255,當(dāng)VARCHAR類(lèi)型的字段大小如果大于255的時(shí)候也會(huì)轉(zhuǎn)換成小的TEXT來(lái)處理。所以也同樣有問(wèn)題。

官方的英文解釋如下:

  1. The error happens because MySQL can index only the first N chars of a BLOB or TEXT column. So The error mainly happen when there is a field/column type of TEXT or BLOB or those belongs to TEXT or BLOB types such as TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, and LONGTEXT that you try to make as primary key or index. With full BLOB or TEXT without the length value, MySQL is unable to guarantee the uniqueness of the column as it’s of variable and dynamic size. So, when using BLOB or TEXT types as index, the value of N must be supplied so that MySQL can determine the key length. However, MySQL doesn’t support a key length limit on TEXT or BLOB. TEXT(88) simply won’t work.  
  2. The error will also pop up when you try to convert a table column from non-TEXT and non-BLOB type such as VARCHAR and ENUM into TEXT or BLOB type, with the column already been defined as unique constraints or index. The Alter Table SQL command will fail.  
  3. The solution to the problem is to remove the TEXT or BLOB column from the index or unique constraint, or set another field as primary key. If you can’t do that, and wanting to place a limit on the TEXT or BLOB column, try to use VARCHAR type and place a limit of length on it. By default, VARCHAR is limited to a maximum of 255 characters and its limit must be specified implicitly within a bracket right after its declaration, i.e VARCHAR(200) will limit it to 200 characters long only.  
  4. Sometimes, even though you don’t use TEXT or BLOB related type in your table, the Error 1170 may also appear. It happens in situation such as when you specify VARCHAR column as primary key, but wrongly set its length or characters size. VARCHAR can only accepts up to 256 characters, so anything such as VARCHAR(512) will force MySQL to auto-convert the VARCHAR(512) to a SMALLTEXT datatype, which subsequently fail with error 1170 on key length if the column is used as primary key or unique or non-

生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線(xiàn)----------------------------
分享到:
------分隔線(xiàn)----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 日日夜夜天天 | 亚洲国产精品影院 | 成人精品在线 | 三级成人av | 精品一区二区免费视频 | 精品久久久久久久久久久久久久久久久 | 欧美精品一区二区三区在线播放 | 成人高清在线视频 | 超碰久热 | 亚洲高清免费视频 | 欧美一级毛片免费的视频 | 亚洲一区二区成人 | 国产精品久久久久久网站 | 精品av天堂毛片久久久借种 | 国产精品第一国产精品 | 欧美一级黄色免费电影 | 日韩欧美一区二区视频 | av中文字幕第一页 | 国产欧美精品一区二区三区 | 黄色免费看片 | 久久久久久久久99精品 | 精品伦精品一区二区三区视频 | 亚洲视频精品一区 | 亚洲欧美视频一区 | 久久国产99| 成人亚洲精品久久久久软件 | 一区二区国产精品 | 2023av在线视频 | 国产亚洲欧美一区二区 | 久久久久久久网站 | 亚洲一区二区三区免费视频 | 97久久久久久久久久久久 | 日韩成人在线观看 | 懂色av一区二区 | 亚洲成人首页 | 国产精品视频在线观看 | 欧美a级成人淫片免费看 | 国产一区二区三区免费观看网站上 | 一区二区免费看 | 五月婷婷激情综合 | 精久久 |