LoginSignup
0
0

Oracle Database 23aiで追加されたSQLの新機能 様々なVALUE句 をFree版で試してみた

Last updated at Posted at 2023-06-15

Oracle Database 23ai から SELECT文 や MERGE 文 でも VALUE句 を使えるようになりました。
早速、SELECT文 で VALUE句 を使って、SQL文中に表を作成してみます。

SQL> SELECT * FROM (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS EXAMPLE(n, c);

         N C
---------- -----
         1 one
         2 two
         3 three

一時的な表を使いたい場合に、CREATE TABLE 文や INSERT 文を使わずに、次のように SELECT 文を書くことができます。

SQL> SELECT T1.n1, T2.c FROM (VALUES (1), (2), (3)) AS T1(n1),
       (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS T2(n2, c)
  3  WHERE T1.n1 = T2.n2;

        N1 C
---------- -----
         1 one
         2 two
         3 three

SELECT 文中に一時的な表を作成することができると、開発効率が上がると思います。
以上、Oracle Database 23ai SQLの新機能 様々な VALUE句 でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0