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

SELECT文の日付フォーマットを変更したい

Posted at

SELECT文の日付フォーマットを変更したい場合、NLS_DATE_FORMATを利用します。

このパラメータの変更方法はいくつかあります。まずはALTER SESSIONで利用する方法があります。

$ sqlplus devuser/Passw0rd@oracle-db-host:1521/XEPDB1

SQL*Plus: Release 21.0.0.0.0 - Production on Sun Jun 30 16:06:51 2024
Version 21.14.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

Last Successful login time: Sun Jun 30 2024 15:57:48 +00:00

Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY/MM/DD HH24:MI:SS';

Session altered.

SQL> SELECT SYSDATE FROM DUAL;

SYSDATE
-------------------
2024/06/30 16:08:17

環境変数で設定することも可能です。

$ env NLS_LANG=Japanese_Japan.AL32UTF8 NLS_DATE_FORMAT='YYYY/MM/DD HH24:MI:SS' sqlplus devuser/Passw0rd@oracle-db-host:1521/XEPDB1

SQL*Plus: Release 21.0.0.0.0 - Production on 日 6月 30 16:14:41 2024
Version 21.14.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

最終正常ログイン時間: 日 6月  30 2024 16:14:18 +00:00


Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
に接続されました。
SQL> SELECT SYSDATE FROM DUAL;

SYSDATE
-------------------
2024/06/30 16:14:50

参考

環境情報

  • Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
  • SQL*Plus 21.14.0.0.0
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?