<legend id='Mu5Hz'><style id='Mu5Hz'><dir id='Mu5Hz'><q id='Mu5Hz'></q></dir></style></legend>
    <bdo id='Mu5Hz'></bdo><ul id='Mu5Hz'></ul>
  • <tfoot id='Mu5Hz'></tfoot>

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

        oracle 给现有表添加自增主键

        时间:2023-09-18
          <bdo id='OjdxN'></bdo><ul id='OjdxN'></ul>
          <legend id='OjdxN'><style id='OjdxN'><dir id='OjdxN'><q id='OjdxN'></q></dir></style></legend>

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

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

                  <tbody id='OjdxN'></tbody>
                  本文介绍了oracle 给现有表添加自增主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想向包含数据的现有表添加一个新的自动增量主列.我该怎么做?

                  I want to add a new auto increment primary column to a existing table which has data. How do I do that?

                  我首先添加了一列,然后尝试添加一个序列,之后我丢失了如何插入该列并将其设为主键.

                  I first added a column and then try to add a sequence after that, I lost how to insert and make that column as primary key.

                  推荐答案

                  假设你的表被称为 t1 而你的主键被称为 id
                  首先,创建序列:

                  Say your table is called t1 and your primary-key is called id
                  First, create the sequence:

                  create sequence t1_seq start with 1 increment by 1 nomaxvalue; 
                  

                  然后创建一个在插入时递增的触发器:

                  Then create a trigger that increments upon insert:

                  create trigger t1_trigger
                  before insert on t1
                  for each row
                     begin
                       select t1_seq.nextval into :new.id from dual;
                     end;
                  

                  这篇关于oracle 给现有表添加自增主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Oracle 的默认日期格式是 YYYY-MM-DD,为什么? 下一篇:SQL - 如何选择具有最大值的列的行

                  相关文章

                    <bdo id='2wOCr'></bdo><ul id='2wOCr'></ul>

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

                    1. <tfoot id='2wOCr'></tfoot>

                      <small id='2wOCr'></small><noframes id='2wOCr'>

                      <legend id='2wOCr'><style id='2wOCr'><dir id='2wOCr'><q id='2wOCr'></q></dir></style></legend>