警告:#1265第1行的列'pdd'的数据被截断 [英] Warning: #1265 Data truncated for column 'pdd' at row 1
问题描述
在将PHPMYADMIN上的PDD
(患者死亡日期)设置为null之前,我一直遇到麻烦;同样在客户端,我可以检查NULL
数据以使用它.
请问有人可以给我解决方案吗?
patientnhs_no hospital_no sex name surname dob address pls pdd
1001001001 6000001 m john smith 1941-01-01 Bournmouth 1 0000-00-00
(如果PDD还活着,则PDD为空;如果死亡,则为死亡日期)
如消息错误所述,您需要增加列的长度以适合您要插入的数据的长度(0000-00-00)
>
编辑1 :
在您发表评论之后,我运行一个测试表:
mysql> create table testDate(id int(2) not null auto_increment, pdd date default null, primary key(id));
Query OK, 0 rows affected (0.20 sec)
插入:
mysql> insert into testDate values(1,'0000-00-00');
Query OK, 1 row affected (0.06 sec)
因此,显然您想在注释状态中向pdd
字段插入NULL值?
您可以通过以下两种方式做到这一点:
方法1:
mysql> insert into testDate values(2,'');
Query OK, 1 row affected, 1 warning (0.06 sec)
方法2:
mysql> insert into testDate values(3,NULL);
Query OK, 1 row affected (0.07 sec)
您无法更改pdd
字段的默认值.这是语法的实现方法(在我的情况下,我一开始将其设置为NULL,现在将其更改为NOT NULL)
mysql> alter table testDate modify pdd date not null;
Query OK, 3 rows affected, 1 warning (0.60 sec)
Records: 3 Duplicates: 0 Warnings: 1
I am having trouble trying to set the PDD
(patient death date) to null on PHPMYADMIN until such death date comes; also on the client end then I can check for NULL
data to use it.
Could anyone suggest me a solution, please ?
patientnhs_no hospital_no sex name surname dob address pls pdd
1001001001 6000001 m john smith 1941-01-01 Bournmouth 1 0000-00-00
(PDD should be null if is alive or death date if died)
As the message error says, you need to Increase the length of your column to fit the length of the data you are trying to insert (0000-00-00)
EDIT 1:
Following your comment, I run a test table:
mysql> create table testDate(id int(2) not null auto_increment, pdd date default null, primary key(id));
Query OK, 0 rows affected (0.20 sec)
Insertion:
mysql> insert into testDate values(1,'0000-00-00');
Query OK, 1 row affected (0.06 sec)
EDIT 2:
So, aparently you want to insert a NULL value to pdd
field as your comment states ?
You can do that in 2 ways like this:
Method 1:
mysql> insert into testDate values(2,'');
Query OK, 1 row affected, 1 warning (0.06 sec)
Method 2:
mysql> insert into testDate values(3,NULL);
Query OK, 1 row affected (0.07 sec)
EDIT 3:
You failed to change the default value of pdd
field. Here is the syntax how to do it (in my case, I set it to NULL in the start, now I will change it to NOT NULL)
mysql> alter table testDate modify pdd date not null;
Query OK, 3 rows affected, 1 warning (0.60 sec)
Records: 3 Duplicates: 0 Warnings: 1
这篇关于警告:#1265第1行的列'pdd'的数据被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!