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

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

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

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

        使用自动递增的 id 列创建 MySQL 视图

        Creating a MySQL view with an auto-incrementing id column(使用自动递增的 id 列创建 MySQL 视图)
        <legend id='8GQAE'><style id='8GQAE'><dir id='8GQAE'><q id='8GQAE'></q></dir></style></legend><tfoot id='8GQAE'></tfoot>
          <i id='8GQAE'><tr id='8GQAE'><dt id='8GQAE'><q id='8GQAE'><span id='8GQAE'><b id='8GQAE'><form id='8GQAE'><ins id='8GQAE'></ins><ul id='8GQAE'></ul><sub id='8GQAE'></sub></form><legend id='8GQAE'></legend><bdo id='8GQAE'><pre id='8GQAE'><center id='8GQAE'></center></pre></bdo></b><th id='8GQAE'></th></span></q></dt></tr></i><div id='8GQAE'><tfoot id='8GQAE'></tfoot><dl id='8GQAE'><fieldset id='8GQAE'></fieldset></dl></div>
              • <bdo id='8GQAE'></bdo><ul id='8GQAE'></ul>

                <small id='8GQAE'></small><noframes id='8GQAE'>

                  <tbody id='8GQAE'></tbody>

                  本文介绍了使用自动递增的 id 列创建 MySQL 视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个用于创建视图的 MySQL 数据库.是否可以为视图中的每一行添加一个自动递增的 id?

                  I have a MySQL database from which a view is created. Is is possible to add an auto-incrementing id for each row in the view?

                  我试过了

                  CREATE ALGORITHM=UNDEFINED DEFINER=`database_name`@`%` SQL SECURITY DEFINER VIEW `MyView` AS 
                  set @i = 0;
                  select  @i:=@i+1 as `id`
                          ...
                  

                  但这在视图中不起作用.

                  but that doesn't work in a View.

                  推荐答案

                  抱歉 - 您不能在 VIEW 中自动递增(尽管您可以在存储过程中执行此操作).

                  Sorry - you can't autoincrement in a VIEW (You could do this in a Stored Procedure though).

                  来自MySQL手册:

                  视图定义受以下限制: SELECT语句不能引用系统或用户变量.

                  A view definition is subject to the following restrictions: The SELECT statement cannot refer to system or user variables.

                  这篇关于使用自动递增的 id 列创建 MySQL 视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                  MySQL cumulative sum grouped by date(按日期分组的 MySQL 累计总和)

                    <legend id='eO3GI'><style id='eO3GI'><dir id='eO3GI'><q id='eO3GI'></q></dir></style></legend>
                    <i id='eO3GI'><tr id='eO3GI'><dt id='eO3GI'><q id='eO3GI'><span id='eO3GI'><b id='eO3GI'><form id='eO3GI'><ins id='eO3GI'></ins><ul id='eO3GI'></ul><sub id='eO3GI'></sub></form><legend id='eO3GI'></legend><bdo id='eO3GI'><pre id='eO3GI'><center id='eO3GI'></center></pre></bdo></b><th id='eO3GI'></th></span></q></dt></tr></i><div id='eO3GI'><tfoot id='eO3GI'></tfoot><dl id='eO3GI'><fieldset id='eO3GI'></fieldset></dl></div>
                      • <bdo id='eO3GI'></bdo><ul id='eO3GI'></ul>
                          <tbody id='eO3GI'></tbody>

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

                      • <tfoot id='eO3GI'></tfoot>