问题描述
我是这个 SQL 的新手;我在更大的程序中看到过类似的问题,目前我无法理解.我正在为我的主页中使用的纸牌游戏制作一个数据库.
I am new to this SQL; I have seen similar question with much bigger programs, which I can't understand at the moment. I am making a database for games of cards to use in my homepage.
我在 Windows 上使用 MySQL Workbench.我得到的错误是:
I am using MySQL Workbench on Windows. The error I get is:
错误代码:1364.字段id"没有默认值
Error Code: 1364. Field 'id' doesn't have a default value
推荐答案
由于 id
是主键,所以不同的行不能有相同的值.尝试更改您的表格,以便 id
自动递增:
As id
is the primary key, you cannot have different rows with the same value. Try to change your table so that the id
is auto incremented:
然后设置主键如下:
一起:
否则,您可以在每次插入时指定id
,注意每次设置不同的值:
Otherwise, you can indicate the id
in every insertion, taking care to set a different value every time:
这篇关于字段“id"没有默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!