A workaround for using Hook_schema to create a database error pdoexception:sqlstate[42000] in Drupal

Source: Internet
Author: User
Tags drupal

The error message is as follows: pdoexception:sqlstate[42000]: Syntax error or Access violation:1071 Specified key was too long; Max key length is 3072 bytes:create TABLE {start_zero_order} (' ID ' int. unsigned not NULL auto_increment COMMENT ' The Ord ER id. ', ' username ' varchar ($) NOT null COMMENT ' xxx ', ' order ' varchar (4096) null DEFAULT null COMMENT ' xxx. ', PRIMARY KE Y (' id '), UNIQUE KEY ' username ' (' username '), INDEX ' order ' (' Order ')) ENGINE = InnoDB DEFAULT CHARACTER SET UTF8 COMMENT ' The taxi order. '; Array () in db_create_table ()

At this point to unload the module, and then modify the data length, specifically, my database supports the key length is 3072, and the different encoding format each character occupies a different length:

Latin1 = 1 byte = 1 character
Uft8 = 3 byte = 1 character
GBK = 2 byte = 1 character

Therefore, the above SQL statement Light Order field needs length 4096*3=12288 bytes, so the error. Change to 512, reinstall module problem resolution.

A workaround for using Hook_schema to create a database error pdoexception:sqlstate[42000] in Drupal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.