开发者

MySQL inserting rows with 0 value in primary key

开发者 https://www.devze.com 2023-03-09 17:00 出处:网络
MySQL (v5.41) on Ubuntu is inserting rows with primary key value as 0. Below is the MyS开发者_Python百科QL table data.

MySQL (v5.41) on Ubuntu is inserting rows with primary key value as 0.

Below is the MyS开发者_Python百科QL table data.

mysql> select id from keywords where text_id = 72;
+----+
| id |
+----+
|  0 |
|  0 |
+----+

| keywords | CREATE TABLE `keywords` (
  `id` int(11) NOT NULL DEFAULT '0',
 `to_user_id` bigint(20) DEFAULT NULL,
  `text_id` int(11) DEFAULT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |

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


set the primary key column to AUTO INCREMENT also.

Like

CREATE TABLE table (
     id INT NOT NULL AUTO_INCREMENT,
     name CHAR(30) NOT NULL,
     PRIMARY KEY (id)
) ENGINE=MyISAM;


You probably don't have the field id as AUTOINCREMENT

0

精彩评论

暂无评论...
验证码 换一张
取 消