自动在自动递增的字段前添加字母 [英] Automatically add letters in front of an auto-increment fieild

查看:72
本文介绍了自动在自动递增的字段前添加字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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.

这篇关于自动在自动递增的字段前添加字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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