当我执行此语句时:
ALTER TABLE person MODIFY COLUMN subcommittee
ENUM('Arts','Bus','HC','IA','Pol','ST','Floater','Student') NULL DEFAULT NULL;
回应是
2801 row(s) affected Records: 2801 Duplicates: 0 Warnings: 0
但是这个声明:
update person set subcommittee = 'Student' where person_pk = 1381;
总是导致此错误消息:
Error Code: 1265. Data truncated for column 'subcommittee' at row 1
(如果您想知道,数据库中有 1381 人,否则我什至不会收到此错误消息。)
选择另一个枚举有效:
update person set subcommittee = 'Floater' where person_pk = 1381;
1 row(s) affected Rows matched: 1 Changed: 1 Warnings: 0
当我使用 PDO 从我的 PHP 应用程序中收到错误时,我首先注意到了这一点,但随后在 MySQLWorkbench 中复制了它,上面的内容是从中获取的。
也许完全删除该列并重新定义它可以解决问题,但这是一个实时数据库,我只想在其中添加一个额外的枚举值(学生)。
我尝试重新键入 alter 语句,将其复制到文本编辑器以检查字符,以及其他一些事情以排除值中奇怪的不可见字符。我还重新排列了值:
ALTER TABLE person MODIFY COLUMN subcommittee
ENUM('Arts','Bus','HC','IA','Pol','ST', 'Student','Floater') NULL DEFAULT NULL;
没有喜悦。
当我搜索了一下时,我看到了一些与修改枚举列相关的错误。有谁知道这是否是 MySQL 错误?
(MySQL 版本 5.5.28。)
一些人要求的一些数据:
mysql> describe person;
+------------------------------+-------------------------------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------------+-------------------------------------------------------------+------+-----+---------+----------------+
| person_pk | int(11) | NO | PRI | NULL | auto_increment |
| name_last | varchar(255) | NO | MUL | | |
| name_first | varchar(255) | YES | | NULL | |
| name_index | int(11) | NO | | 0 | |
| name_middle | varchar(255) | YES | | NULL | |
| name_spouse_or_partner_first | varchar(255) | YES | | NULL | |
| name_spouse_or_partner_last | varchar(255) | YES | | NULL | |
| name_legal_first | varchar(255) | YES | | NULL | |
| name_legal_middle | varchar(255) | YES | | NULL | |
| name_legal_last | varchar(255) | YES | | NULL | |
| prefix | varchar(255) | YES | | NULL | |
| suffix | varchar(255) | YES | | NULL | |
| salutation | varchar(255) | YES | | NULL | |
| home_street1 | varchar(255) | YES | | NULL | |
| home_street2 | varchar(255) | YES | | NULL | |
| home_city | varchar(255) | YES | | NULL | |
| home_state | varchar(255) | YES | | NULL | |
| home_zip | varchar(255) | YES | | NULL | |
| home_country | varchar(255) | YES | | NULL | |
| work_org | varchar(255) | YES | | NULL | |
| work_street1 | varchar(255) | YES | | NULL | |
| work_street2 | varchar(255) | YES | | NULL | |
| work_city | varchar(255) | YES | | NULL | |
| work_state | varchar(255) | YES | | NULL | |
| work_zip | varchar(255) | YES | | NULL | |
| work_country | varchar(255) | YES | | NULL | |
| phone_home | varchar(255) | YES | | NULL | |
| phone_work | varchar(255) | YES | | NULL | |
| phone_mobile | varchar(255) | YES | | NULL | |
| phone_fax | varchar(255) | YES | | NULL | |
| phone5 | varchar(255) | YES | | NULL | |
| phone6 | varchar(255) | YES | | NULL | |
| email | varchar(255) | YES | | NULL | |
| email2 | varchar(255) | YES | | NULL | |
| website | varchar(255) | YES | | NULL | |
| preferred_communication | enum('home','work','mobile','email','mail','special') | YES | | NULL | |
| preferred_communication_text | varchar(255) | YES | | NULL | |
| preferred_address | enum('home','work') | YES | | NULL | |
| use_housing | tinyint(1) | YES | | NULL | |
| smoker | tinyint(1) | YES | | NULL | |
| pet_allergies | tinyint(1) | YES | | NULL | |
| pets | tinyint(1) | YES | | NULL | |
| kids | tinyint(1) | YES | | NULL | |
| physical_considerations | text | YES | | NULL | |
| dietary_needs | text | YES | | NULL | |
| appellation | varchar(255) | YES | | NULL | |
| bio | text | YES | | NULL | |
| photo | varchar(255) | YES | | NULL | |
| include_in_directory | tinyint(1) | YES | | NULL | |
| participant_notes | text | YES | | NULL | |
| contact_notes | text | YES | | NULL | |
| available_1A | tinyint(1) | YES | | NULL | |
| available_1P | tinyint(1) | YES | | NULL | |
| available_2A | tinyint(1) | YES | | NULL | |
| available_2P | tinyint(1) | YES | | NULL | |
| available_3A | tinyint(1) | YES | | NULL | |
| available_3P | tinyint(1) | YES | | NULL | |
| available_4A | tinyint(1) | YES | | NULL | |
| available_4P | tinyint(1) | YES | | NULL | |
| available_5A | tinyint(1) | YES | | NULL | |
| available_5P | tinyint(1) | YES | | NULL | |
| interest_x_dis | tinyint(1) | YES | | NULL | |
| interest_arts | tinyint(1) | YES | | NULL | |
| interest_bus | tinyint(1) | YES | | NULL | |
| interest_hc | tinyint(1) | YES | | NULL | |
| interest_ia | tinyint(1) | YES | | NULL | |
| interest_med | tinyint(1) | YES | | NULL | |
| interest_pol | tinyint(1) | YES | | NULL | |
| interest_st | tinyint(1) | YES | | NULL | |
| venue_manager | tinyint(1) | YES | | NULL | |
| committee_arts | tinyint(1) | YES | | NULL | |
| committee_bus | tinyint(1) | YES | | NULL | |
| committee_hc | tinyint(1) | YES | | NULL | |
| committee_ia | tinyint(1) | YES | | NULL | |
| committee_pol | tinyint(1) | YES | | NULL | |
| committee_st | tinyint(1) | YES | | NULL | |
| committee_students | tinyint(1) | YES | | NULL | |
| committee_housing | tinyint(1) | YES | | NULL | |
| committee_moderator | tinyint(1) | YES | | NULL | |
| committee_volunteer | tinyint(1) | YES | | NULL | |
| committee_fundraising | tinyint(1) | YES | | NULL | |
| committee_office | tinyint(1) | YES | | NULL | |
| committee_other | tinyint(1) | YES | | NULL | |
| committee_notes | text | YES | | NULL | |
| houser_fk | int(11) | YES | MUL | NULL | |
| housed_fk | int(11) | YES | MUL | NULL | |
| contact_fk | int(11) | YES | MUL | NULL | |
| hyphen_fk | int(11) | YES | MUL | NULL | |
| introduced_by_fk | int(11) | YES | MUL | NULL | |
| committee_contact_fk | int(11) | YES | MUL | NULL | |
| donor | tinyint(1) | YES | | NULL | |
| houser | tinyint(1) | YES | | NULL | |
| moderator | tinyint(1) | YES | | NULL | |
| producer | tinyint(1) | YES | | NULL | |
| committee_member | tinyint(1) | YES | | NULL | |
| participant | tinyint(1) | YES | | NULL | |
| fan | tinyint(1) | YES | | NULL | |
| student | tinyint(1) | YES | | NULL | |
| volunteer | tinyint(1) | YES | | NULL | |
| staff | tinyint(1) | YES | | NULL | |
| companion | tinyint(1) | YES | | NULL | |
| id_number | int(11) | YES | | NULL | |
| deceased | tinyint(1) | YES | | NULL | |
| load_donation | tinyint(1) | YES | | NULL | |
| load_panel | tinyint(1) | YES | | NULL | |
| load_participant | tinyint(1) | YES | | NULL | |
| conversion_note | text | YES | | NULL | |
| replacedby_fk | int(11) | YES | MUL | NULL | |
| companion_to_fk | int(11) | YES | MUL | NULL | |
| name_for_program | varchar(255) | YES | | NULL | |
| gender | enum('male','female') | YES | | NULL | |
| subcommittee | enum('Arts','Bus','HC','IA','Pol','ST','Student','Floater') | YES | | NULL | |
| companion_type | enum('spouse/partner','child','friend') | YES | | NULL | |
| days_here | varchar(6) | YES | | NULL | |
| new_or_returning | enum('new','returning') | YES | | NULL | |
| confirmation_sheet | tinyint(1) | YES | | NULL | |
| bio_in | tinyint(1) | YES | | NULL | |
| photo_in | tinyint(1) | YES | | NULL | |
| birthday | date | YES | | NULL | |
| date_topics_letter_sent | date | YES | | NULL | |
| topics_received | tinyint(1) | YES | | NULL | |
| rating | enum('A','B','C','D','F') | YES | | NULL | |
| flight_info_received | tinyint(1) | YES | | NULL | |
| transportation_email_sent | tinyint(1) | YES | | NULL | |
| bringing_children | tinyint(1) | YES | | NULL | |
| date_address_verfied | date | YES | | NULL | |
+------------------------------+-------------------------------------------------------------+------+-----+---------+----------------+
126 rows in set (0.01 sec)
mysql> select person_pk, subcommittee from person where person_pk = 1381;
+-----------+--------------+
| person_pk | subcommittee |
+-----------+--------------+
| 1381 | Floater |
+-----------+--------------+
1 row in set (0.00 sec)