<bdo id='k8m0B'></bdo><ul id='k8m0B'></ul>

<i id='k8m0B'><tr id='k8m0B'><dt id='k8m0B'><q id='k8m0B'><span id='k8m0B'><b id='k8m0B'><form id='k8m0B'><ins id='k8m0B'></ins><ul id='k8m0B'></ul><sub id='k8m0B'></sub></form><legend id='k8m0B'></legend><bdo id='k8m0B'><pre id='k8m0B'><center id='k8m0B'></center></pre></bdo></b><th id='k8m0B'></th></span></q></dt></tr></i><div id='k8m0B'><tfoot id='k8m0B'></tfoot><dl id='k8m0B'><fieldset id='k8m0B'></fieldset></dl></div>
  • <small id='k8m0B'></small><noframes id='k8m0B'>

    <tfoot id='k8m0B'></tfoot>

    <legend id='k8m0B'><style id='k8m0B'><dir id='k8m0B'><q id='k8m0B'></q></dir></style></legend>

        MySQL 自动递增自定义值

        时间:2023-07-18
      1. <i id='z1O5u'><tr id='z1O5u'><dt id='z1O5u'><q id='z1O5u'><span id='z1O5u'><b id='z1O5u'><form id='z1O5u'><ins id='z1O5u'></ins><ul id='z1O5u'></ul><sub id='z1O5u'></sub></form><legend id='z1O5u'></legend><bdo id='z1O5u'><pre id='z1O5u'><center id='z1O5u'></center></pre></bdo></b><th id='z1O5u'></th></span></q></dt></tr></i><div id='z1O5u'><tfoot id='z1O5u'></tfoot><dl id='z1O5u'><fieldset id='z1O5u'></fieldset></dl></div>

            <small id='z1O5u'></small><noframes id='z1O5u'>

                <tfoot id='z1O5u'></tfoot>
                <legend id='z1O5u'><style id='z1O5u'><dir id='z1O5u'><q id='z1O5u'></q></dir></style></legend>
                  <bdo id='z1O5u'></bdo><ul id='z1O5u'></ul>
                    <tbody id='z1O5u'></tbody>
                  本文介绍了MySQL 自动递增自定义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 mysql 数据库中创建一列,该列自动递增 1,但从 0-Z 开始,然后滚动.

                  I am trying to make a column in a mysql database that auto increments by one but goes from 0-Z and then rolls.

                  例如000, 001, 002, ..., 009, 00A, 00B, ..., 00Z, 010, ..., 0ZZ, ..., 100.

                  For example 000, 001, 002, ..., 009, 00A, 00B, ..., 00Z, 010, ..., 0ZZ, ..., 100.

                  我想让数据库通过自动递增字段创建列.

                  I would like to have the database create the column through an auto incrementing field.

                  我的想法是:

                  1. 为从 0 到 36 的每个字符创建一列,然后将第 N 行(其中 N 是最低有效数字)自动增加 1.然后在每列上添加一个触发器,以便在列时将 1 添加到 N-1 列N 达到 36.
                  2. 创建一个包含 36 行的表格,其中每行包含一个字符 0-Z,并使用与上述类似的进位逻辑从表格中提取适当的字符
                  3. 创建一个存储过程来执行第 1 项中的相应逻辑
                  4. 让实际程序生成一个值并将其插入表中
                  5. 有一个有规律的自动递增值并计算序列中的下一个值(这是最不理想的,因为它使得仅仅在数据库中查看的人难以解析)

                  我希望有一些优雅的东西可以允许它像一个内置的机制来做到这一点,我只是不知道.我对存储过程/触发器一无所知,因此将不胜感激.我认为最简单的方法是为字符创建一个查找表,当到达第 36 行时,它被重置为 0,然后有一个进位到第 N-1 行.

                  I was hoping that there was something elegant which would allow for this like a built in mechanism to do this that I just do not know. I have no knowledge on stored procedures / triggers so help with it would be greatly appreciated. I think the easiest way would be to have a lookup table for the characters and when row 36 is reached it is reset to 0 and then there is a carry to row N-1.

                  推荐答案

                  根据您的意见,我的建议是:

                  Based on your comments, my recommendation is to do the following:

                  使用常规整数 auto_increment 列作为行的主键,然后使用 varchar 类型或 *text 类型之一(取决于您的 mysql 服务器版本和数据存储要求)的列来存储您的标识符"客户使用的.

                  Use a regular integer auto_increment column as the primary key for the row, and then have a column of type varchar or one of the *text types (depending on your mysql server version and data storage requirements) to store your "identifier" that the customer uses.

                  标识符可以使用触发器自动生成.

                  The identifier can be auto-generated using a trigger.

                  如果您要根据标识符进行查找(即用户可能输入标识符以跳转到"记录),您将需要该列上的索引.

                  If you're going to do lookups based on the identifier (i.e. perhaps the user enters an identifier to "jump to" a record) you will want an index on that column.

                  这篇关于MySQL 自动递增自定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:更改步骤 auto_increment 字段增量 下一篇:自动递增 - 每年自动重置

                  相关文章

                      <legend id='HDbbz'><style id='HDbbz'><dir id='HDbbz'><q id='HDbbz'></q></dir></style></legend>

                    1. <tfoot id='HDbbz'></tfoot>
                        <bdo id='HDbbz'></bdo><ul id='HDbbz'></ul>

                    2. <i id='HDbbz'><tr id='HDbbz'><dt id='HDbbz'><q id='HDbbz'><span id='HDbbz'><b id='HDbbz'><form id='HDbbz'><ins id='HDbbz'></ins><ul id='HDbbz'></ul><sub id='HDbbz'></sub></form><legend id='HDbbz'></legend><bdo id='HDbbz'><pre id='HDbbz'><center id='HDbbz'></center></pre></bdo></b><th id='HDbbz'></th></span></q></dt></tr></i><div id='HDbbz'><tfoot id='HDbbz'></tfoot><dl id='HDbbz'><fieldset id='HDbbz'></fieldset></dl></div>
                    3. <small id='HDbbz'></small><noframes id='HDbbz'>