MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length MySQL Error 1170 (42000): blob / TULISAN Kolom Digunakan dalam Spesifikasi Kunci Tanpa Kunci Panjang
When creating a new table or altering an existing table with primary keys, unique constraints and indexes, or when defining a new index with Alter Table manipulation statement in MySQL database, the following error may occur and prohibit the the command from completing: Ketika membuat sebuah tabel baru atau mengubah yang sudah ada tabel dengan kunci utama, unik kendala dan indeks, atau ketika mendefinisikan baru dengan indeks Alter Tabel manipulasi pernyataan di database MySQL, berikut ini mungkin terjadi kesalahan dan melarang perintah dari menyelesaikan:
ERROR 1170 (42000): BLOB/TEXT column 'field_name' used in key specification without a key length ERROR 1170 (42000): blob / TULISAN kolom 'field_name' utama yang digunakan dalam spesifikasi panjang tanpa kunci
The error happens because MySQL can index only the first N chars of a BLOB or TEXT column. Kesalahan yang terjadi karena MySQL hanya dapat indeks pertama N chars dari blob atau TULISAN kolom. 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. Jadi kesalahan yang terjadi terutama bila ada bidang / jenis kolom TEXT atau blob atau orang-orang kepunyaan TULISAN blob atau jenis seperti TINYBLOB, MEDIUMBLOB, LONGBLOB, TINYTEXT, MEDIUMTEXT, dan LONGTEXT bahwa Anda mencoba membuat sebagai kunci utama atau indeks. 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. Dengan penuh TULISAN blob atau tanpa nilai panjang, MySQL tidak bisa menjamin keunikan dari kolom karena dari variabel yang dinamis dan ukuran. So, when using BLOB or TEXT types as index, the value of N must be supplied so that MySQL can determine the key length. Jadi, bila menggunakan blob atau TULISAN jenis sebagai indeks, nilai N harus diberikan agar MySQL dapat menentukan panjang kunci. However, MySQL doesn't support limit on TEXT or BLOB. Namun, MySQL tidak mendukung batasan TULISAN atau blob. TEXT(88) simply won't work. TULISAN (88) hanya tidak akan berfungsi.
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. Kesalahan juga akan pop up ketika anda mencoba untuk mengubah kolom tabel dari non-TULISAN dan non-gumpal seperti tipe VARCHAR dan enum menjadi TULISAN blob atau jenis, dengan kolom yang sudah ditetapkan sebagai kendala atau indeks yang unik. The Alter Table SQL command will fail. Alter Tabel SQL yang akan gagal.
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. Solusi untuk masalah ini adalah untuk menghapus TULISAN blob atau kolom dari indeks atau unik kendala, atau bidang lain yang ditetapkan sebagai kunci utama. 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. Jika Anda tidak dapat melakukan itu, dan ingin menempatkan batas pada kolom blob atau TULISAN, cobalah untuk menggunakan VARCHAR jenis dan menempatkan batas panjang di dalamnya. 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, ie VARCHAR(200) will limit it to 200 characters long only. Secara default, VARCHAR dibatasi hingga maksimal 255 karakter dan batas harus ditentukan mutlak dalam golongan kanan setelah deklarasi, yaitu VARCHAR (200) akan membatasi ke hanya 200 karakter.
Sometimes, even though you don't use TEXT or BLOB related type in your table, the Error 1170 may also appear. Terkadang, walaupun Anda tidak menggunakan TULISAN blob atau jenis terkait dalam tabel, maka Kesalahan Mei 1170 juga muncul. It happens in situation such as when you specify VARCHAR column as primary key, but wrongly set its length or characters size. Itu terjadi dalam situasi seperti saat Anda menentukan VARCHAR kolom sebagai kunci utama, namun karena salah mengatur ukuran panjang atau karakter. 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-unique index. VARCHAR hanya dapat menerima sampai dengan 256 karakter, jadi apapun seperti VARCHAR (512) akan memaksa MySQL ke auto-mengkonversikan VARCHAR (512) ke SMALLTEXT data, yang kemudian gagal dengan kesalahan pada 1170 kunci jika panjang kolom yang digunakan sebagai dasar atau kunci unik atau non-unik indeks. To solve this problem, specify a figure less than 256 as the size for VARCHAR field. Untuk mengatasi masalah ini, menetapkan angka kurang dari 256 sebagai ukuran untuk VARCHAR lapangan.
IMPORTANT : The page is machine translated and provided "as is" without warranty. PENTING: Halaman yang diterjemahkan mesin dan diberikan "sebagaimana adanya" tanpa jaminan. Machine translation may be difficult to understand. Mesin terjemahan mungkin sulit dimengerti. Please refer to Silakan merujuk ke original English article artikel asli Inggris whenever possible. bila memungkinkan.
Related Articles Artikel Terkait
- How to Find and Replace Text in MySQL Database using SQL Cara Cari dan Ganti Teks di MySQL Database menggunakan SQL
- WordPress MySQL SQL Query Error in WPDB Class Wordpress MySQL Query SQL Kesalahan dalam WPDB Kelas
- Text Copying Disabled (Fix Copy and Paste Not Working Error) Menyalin teks Cacat (Fix Copy dan Paste Kesalahan Tidak Bekerja)
- Change and Reset MySQL root Password Mengubah dan Reset MySQL root Password
- Adding Extra More Fields to WordPress Write/Edit Post/Page Right Column Menambahkan Extra Lagi Fields ke Wordpress Write / Edit Posting / Kolom Halaman Kanan
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Menghapus atau Trim Pertama atau Sedikit Terakhir Karakter dalam MySQL Database dengan SQL
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Instalasi Web Server di FreeBSD 6.0 with Apache 2.2, PHP MySQL 5,0 dan 5 - Bagian 3
- MySQL Database Performance Tuning Best Practices Video Tutorial Kinerja MySQL Database Tuning Jawaban Praktik Video Tutorial
- Check and Optimize MySQL Database Automatically with Crontab/Cron Memeriksa dan Optimalkan MySQL Database secara otomatis dengan crontab / Cron
- ORA-02449 Oracle Drop Table Error Ora-02449 Oracle Drop Tabel Kesalahan










































April 30th, 2009 22:32 30 April, 2009 22:32
Thank you for the post. Terima kasih atas posting tersebut.
I need a key that is longer then 256. Saya perlu kunci yang lagi kemudian 256.
What can I do? Apa yang bisa saya lakukan?
googling it for the past 3 hours with no luck… Googling itu selama 3 jam tanpa luck ...
(Paco Zarabozo comment did not work for me) (Paco Zarabozo komentar didn't work for me)
December 13th, 2008 22:20 13 Des 2008 22:20
[...] I ran into some problems, I back-pedalled to square one. [...] Aku berlari ke dalam beberapa masalah, saya kembali ke alun-alun-pedalled satu. Thankfully my backup restored the Latin1 database without any [...] Thankfully Kontak cadangan yang dikembalikan latin1 database tanpa [...]
October 29th, 2008 10:16 29 Okt 2008 10:16
Well, here's another solution. Well, berikut solusi yang lain. You can actually specify the key length for your index while keeping your field as longtext. Anda benar-benar dapat menentukan tombol panjang untuk indeks sekaligus menjaga Anda sebagai bidang longtext. This is an example: Ini adalah contoh:
create table messages ( membuat tabel pesan (
id int(20) not null auto_increment, id int (20) not null auto_increment,
message longtext, pesan longtext,
index (message(996), id) indeks (pesan (996), id)
); );
desc messages; desc pesan;
show index from messages; menunjukkan indeks dari pesan;
996 is the maximium key length mySQL has accepted for me. 996 adalah maximium kunci mySQL telah menerima panjang bagi saya.
Cheers, Ceria,
Paco Paco
October 27th, 2008 19:50 27 Okt 2008 19:50
Thanks a lot! Thanks a lot!
October 6th, 2008 03:50 6 Okt 2008 03:50
Thank you very much. Terima kasih banyak. I had this problem and you were a life saver! Aku masalah ini dan anda a life saver!
March 7th, 2008 04:15 7 Mar 2008 04:15
Thanks, very good defined Thanks, very good ditetapkan
February 23rd, 2008 03:40 23 Feb 2008 03:40
Thanks for the post. Thanks for posting. Very helpful. Very helpful.
February 20th, 2008 02:45 20 Feb 2008 02:45
Thanks! Terima kasih! Very useful post. Posting sangat bermanfaat.
August 30th, 2007 18:33 30 Agust 2007 18:33
Thanks for putting this up. Thanks for putting this up. I didn't get the error and you saved me a lot o frustration. Aku tidak pernah mendapatkan kesalahan dan Anda disimpan me alot o frustrasi. I'd put you in the 'Goog people' category anytime I'd menempatkan anda di 'goog orang' kategori kapanpun