3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Oracle Database 23aiで追加されたSQLの新機能 Boolean型 をFree版で試してみた

Last updated at Posted at 2023-06-15

Oracle Database 23ai から Boolean型 を使えるようになりました。
早速、Boolean型 を試してみます。

Boolean型が列にある表を作成します。

SQL> CREATE TABLE example (id NUMBER, c1 BOOLEAN, c2 BOOL);

Table created.

Boolean型の列がある表にレコードを挿入します。

SQL> INSERT INTO example VALUES (1, TRUE, NULL);

1 row created.

SQL> INSERT INTO example VALUES (2, FALSE, true);

1 row created.

Boolean型の列がある表を検索します。

SQL> SELECT * FROM example;

        ID C1          C2
---------- ----------- -----------
         1 TRUE
         2 FALSE       TRUE

Boolean型自体が論理値なので、WHERE句にBoolean型のみで評価できます。

SQL> SELECT * FROM example WHERE C1;

        ID C1          C2
---------- ----------- -----------
         1 TRUE

Boolean型を型変換してみます。

SQL> SELECT TO_BOOLEAN(ID -1) C3, TO_NUMBER(C1) C4, TO_CHAR(C1) C5 FROM example;

C3                  C4 C5
----------- ---------- -----
FALSE                1 TRUE
TRUE                 0 FALSE

以上、Boolean型のデータを扱うことができました。

3
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?