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

        <small id='3ONtd'></small><noframes id='3ONtd'>

        Oracle:如果一行不存在,如何插入

        时间:2023-09-18

        1. <tfoot id='GupGo'></tfoot>

              • <bdo id='GupGo'></bdo><ul id='GupGo'></ul>

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

                <legend id='GupGo'><style id='GupGo'><dir id='GupGo'><q id='GupGo'></q></dir></style></legend>
                  <tbody id='GupGo'></tbody>
                  <i id='GupGo'><tr id='GupGo'><dt id='GupGo'><q id='GupGo'><span id='GupGo'><b id='GupGo'><form id='GupGo'><ins id='GupGo'></ins><ul id='GupGo'></ul><sub id='GupGo'></sub></form><legend id='GupGo'></legend><bdo id='GupGo'><pre id='GupGo'><center id='GupGo'></center></pre></bdo></b><th id='GupGo'></th></span></q></dt></tr></i><div id='GupGo'><tfoot id='GupGo'></tfoot><dl id='GupGo'><fieldset id='GupGo'></fieldset></dl></div>
                  本文介绍了Oracle:如果一行不存在,如何插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 PL/SQL (oracle) 中插入不存在的行的最简单方法是什么?

                  What is the easiest way to INSERT a row if it doesn't exist, in PL/SQL (oracle)?

                  我想要类似的东西:

                  IF NOT EXISTS (SELECT * FROM table WHERE name = 'jonny') THEN
                    INSERT INTO table VALUES ("jonny", null);
                  END IF;
                  

                  但它不起作用.

                  注意:此表有 2 个字段,例如 nameage.但只有名字是PK.

                  Note: this table has 2 fields, say, name and age. But only name is PK.

                  推荐答案

                  INSERT INTO table
                  SELECT 'jonny', NULL
                    FROM dual -- Not Oracle? No need for dual, drop that line
                   WHERE NOT EXISTS (SELECT NULL -- canonical way, but you can select
                                                 -- anything as EXISTS only checks existence
                                       FROM table
                                      WHERE name = 'jonny'
                                    )
                  

                  这篇关于Oracle:如果一行不存在,如何插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SQL - 如何选择具有最大值的列的行 下一篇:oracle区分大小写的原因?

                  相关文章

                • <legend id='ky2c2'><style id='ky2c2'><dir id='ky2c2'><q id='ky2c2'></q></dir></style></legend>
                • <small id='ky2c2'></small><noframes id='ky2c2'>

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

                    1. <tfoot id='ky2c2'></tfoot>