在MySQL中是否可以在自动递增前面附加一个字母.我的数据库中有几个表,其中一些表具有通过自动增量创建的唯一ID.我希望能够通过前面的字母来区分自动生成的数字.
Is it possible to attach a letter in front of an auto-increment in MySQL. I have several tables in my database, some of which have unique id's created by auto-increment. I want to be able to distinguish between the auto-generated numbers by a letter at the front.
这不是绝对必需的功能,但只会帮助简化小型任务.
This is not a feature which is absolutely required but it would just help making small tasks easy.
推荐答案不幸的是,您不能这样做.至少不是在sql中.自动增量字段是整数类型,因此在其中添加字母会违反约束.
Unfortunately you cannot do that. At least not in sql. An autoincrement field is of integer type, so adding a letter there violates the constraint.
您可以在下面的链接中找到有关此问题的某种解决方案.
You can have a look to the link below for some sort of a solution to this problem.
MySQL自动增量和一列中的字母数字
我希望这可以指导您正确的方向.
I hope that this can guide you to the right direction.
更多推荐
自动在自动递增的字段前添加字母
发布评论