mysql 1054 42s22_mysql-错误1054(42S22):“字段列表”中的未知...

A:

create table users_questions2

( user_id int not null,

question_id int not null,

mcopt_id int not null,

timestamp timestamp not null,

marks int not null

);

describe users_questions2;

+-------------+-----------+------+-----+-------------------+-----------------------------+

| Field | Type | Null | Key | Default | Extra |

+-------------+-----------+------+-----+-------------------+-----------------------------+

| user_id | int(11) | NO | | NULL | |

| question_id | int(11) | NO | | NULL | |

| mcopt_id | int(11) | NO | | NULL | |

| timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |

| marks | int(11) | NO | | NULL | |

+-------------+-----------+------+-----+-------------------+-----------------------------+

INSERT INTO users_questions2 (user_id, question_id, mcopt_id, timestamp) VALUES (50053, 875, 3092, '2015-08-22 18:01:44');

Error Code: 1364. Field 'marks' doesn't have a default value 0.047 sec

INSERT INTO users_questions2 (user_id, question_id, mcopt_id, timestamp,marks) VALUES (50053, 875, 3092, '2015-08-22 18:01:44',1);

-- 1 row(s) affected

INSERT INTO users_questions2 (user_id, question_id, mcopt_id, timestamp,marks) VALUES (50053, 875, 3092, '2015-08-22 18:01:44',null);

Error Code: 1048. Column 'marks' cannot be null 0.000 sec

B:

drop table users_questions2;

create table users_questions2

( user_id int null,

question_id int null,

mcopt_id int null,

timestamp timestamp null,

marks int null

);

describe users_questions2;

+-------------+-----------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------------+-----------+------+-----+---------+-------+

| user_id | int(11) | YES | | NULL | |

| question_id | int(11) | YES | | NULL | |

| mcopt_id | int(11) | YES | | NULL | |

| timestamp | timestamp | YES | | NULL | |

| marks | int(11) | YES | | NULL | |

+-------------+-----------+------+-----+---------+-------+

INSERT INTO users_questions2 (user_id, question_id, mcopt_id, timestamp) VALUES (50053, 875, 3092, '2015-08-22 18:01:44');

1 row(s) affected

因此,让我的描述表看起来像您的描述表的唯一方法是它们不是空列(上面的A节).

这意味着您的列不接受空值.

编辑:

show variables like "%version%";

+-------------------------+------------------------------+

| Variable_name | Value |

+-------------------------+------------------------------+

| innodb_version | 5.6.24 |

| protocol_version | 10 |

| slave_type_conversions | |

| version | 5.6.24-log |

| version_comment | MySQL Community Server (GPL) |

| version_compile_machine | x86_64 |

| version_compile_os | Win64 |

+-------------------------+------------------------------+

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值