通过SQL语句手动插入表,但键是自动增量 [英] Insert manually into a table by SQL statement, but key is autoincremented

查看:95
本文介绍了通过SQL语句手动插入表,但键是自动增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个用户表,并且 id 列是主键,并自动递增。

Let's say I have a table of users and the id column is the primary key and auto incremented.

我想通过此语句手动尝试添加用户:

I want to just try and add user manually by this statement:

INSERT INTO table_name (id, username, password)  
VALUES (?, Mike, Mike);

但我不想指定 value,只是想添加到下一行。

but I don't want to specify the ? value, just want to add to the next row.

感谢大家,我忘了将id列设置为自动递增。

Thanks everyone, I forgot to set the id column to auto increment. it works now.

推荐答案

所以只是不要使用它...做这样..

So just don't use it...do it like this..

请务必使用单引号插入字符串

And be sure you use single quotes for inserting strings

INSERT INTO table_name (username, password)
VALUES ('Mike', 'Mike');



< ,SQL将自动将 id 字段的值增加1

这篇关于通过SQL语句手动插入表,但键是自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆