MySQL:Specified key was too long; max key length is 767 bytes
下面的SQL語句
CREATE TABLE subscription (
subscriptionid varchar(767) NOT NULL PRIMARY KEY,
params blob,
dest varchar(1023),
sched blob,
trigg varchar(1023),
initialrecordingtime timestamp,
exportifempty boolean,
queryname varchar(1023),
lastexecuted timestamp
);
CREATE TABLE subscription (
subscriptionid varchar(767) NOT NULL PRIMARY KEY,
params blob,
dest varchar(767),
sched blob,
trigg varchar(767),
initialrecordingtime timestamp,
exportifempty boolean,
queryname varchar(767),
lastexecuted timestamp
);
依然是這個錯誤!!
將mysql資料庫指令碼中的unique index欄位從原來的varchar(256)改成varchar(1024),再次執行報錯:
ERROR 1071 (42000) at line 482 in file: 'db/sm1.sql': Specified key was too long; max key length is 767 bytes
以前寫過一篇文章,也是關於這個問題的
在該文中,我經過試驗,發現如果將varchar型別的unique index/key設定成最大383,就不會出現問題了。
其實這個問題還有一個解,那就是指定索引的長度:
對於CHAR和VARCHAR列,只用一列的一部分就可建立索引。建立索引時,使用col_name(length)語法,對字首編制索引。字首包括每列值的前length個字元。BLOB和TEXT列也可以編制索引,但是必須給出字首長度。
那麼在不改變欄位長度的情況下,通過指定索引長度為一個較小的值,就可以避免出現這個問題了。
UNIQUE INDEX (content(32)),
又如,
此處展示的語句用於建立一個索引,索引使用列名稱的前10個字元。
CREATE INDEX part_of_name ON customer (name(10));因為多數名稱的前10個字元通常不同,所以此索引不會比使用列的全名建立的索引速度慢很多。
相關文章
- Specified key was too long; max key length is 1000 bytes
- 偶遇ERROR 1071 (42000): Specified key was too long; max key length is 767 bytesError
- 解決 Specified key was too long ... 767 bytes 的本質問題
- mysql specified key was too long與Index column size too large. The maximum column size is 767 bytes.MySqlIndex
- Laravel 5.4 常見錯誤:Specified key was too longLaravel
- Laravel 5.5 資料遷移問題:Specified key was too longLaravel
- 執行遷移檔案報錯 1071 Specified key was too long.
- Index column size too large. The maximum column size is 767 bytesIndex
- MySQL建立表失敗:Index column size too large. The maximum column size is 767 bytesMySqlIndex
- Index column size too large. The maximum column size is 767 bytes.Index
- MySQL 5.7 到 5.6,出現 Index column size too large. The maximum column size is 767 bytesMySqlIndex
- insert:key too large to index…Index
- 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- MySQL資料庫index column size too large. the maximum column size is 767 bytes問題解決MySql資料庫Index
- [Err] 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- mysql5.7 資料匯入5.6 Index column size too large. The maximum column size is 767 bytes.MySqlIndex
- mysql中key 、primary key 、unique key 與index區別MySqlIndex
- mysql drop keyMySql
- [報錯:字元太長] SQLSTATE [42000]: Syntax error or access violation: 1071 Specified key was t oo long;字元SQLError
- Mysql Key Buffer SizeMySql
- MySQL KEY分割槽MySql
- laravel出現The cipher and / or key length are invalid 的Bug除錯Laravel除錯
- MGETkey[key…]
- mysql Index column size too large 超過767錯誤解決方案(轉)MySqlIndex
- mysql RSA private key file not foundMySql
- MySQL Next-Key LockMySql
- mysql INSERT ... ON DUPLICATE KEY UPDATEMySql
- js keyup、keypress和keydown事件JS事件
- mysql的max_connections和Too many connectionsMySql
- Max length of title attribute in htmlHTML
- With KEY & With Table KEY 的使用
- keyup,keypress,keydown事件的區別事件
- MySQL_插入更新 ON DUPLICATE KEY UPDATEMySql
- Redis熱點key大keyRedis
- Mysql提示 “ Got a packet bigger than 'max_allowed_packet' bytes”MySqlGo
- keycloak~關於session idle和session max的解釋Session
- error: "net.ipv4.ip_conntrack_max" is an unknown keyError
- WAITED TOO LONG FOR A ROW CACHE ENQUEUE LOCK!AIENQ