Oracleのキーワード


うーん...どっちがどっちを書いて、整理して
1、decode
select decode(sex,1,' ',' ') from student

つまり、Studentテーブルの中でsexが1の場合、sexは男性で、そうでなければ女性です.
2、時間書式
select to_char(date,'yyyy-MM-dd hh24:mi:ss') date from Time

クエリーの時間はこの形式で出力します.
3、isEquals動的接合用sql
--------転自https://www.cnblogs.com/warrior4236/p/5978752.html
次の例を示します.
statusのステータスが0の場合、attribute 1が更新されます.ステータスが1の場合、attribute 2が更新されます.
ステータスが2の場合、attribute 3が更新されます.

update  cis_customer  set  code_id  = #codeId# ,
  
            attribute1=#attribute1#  
          
            attribute2=#attribute2#  
          
            attribute3=#attribute3#
where  id = #id#

4、isNotEmpty
------------------転自https://www.cnblogs.com/warrior4236/p/5978752.html
次の例を示します.
クエリーcis_Customerという表は、属性aaaが空でない場合、条件aaa=#aaa#をつなぎ合わせます.
bbbが空でない場合、条件bbb=#bbb#をつなぎ合わせる.属性cccが空でない場合、条件ccc=#ccc#をつなぎ合わせる.
  

5、order by
このorder byは比較的基礎的な言葉で、昨日見たときによく知らない点を見つけて、手当たり次第に整理しました.
select * from student order by age

この文は、Studentテーブルをageサイズでソートし、ソート方法が書かれていない場合、デフォルトは昇順(ASC)です.
select * from student order by age desc

この文は、Studioテーブルをageサイズでソートし、降順でソートします(DESC)
  • ASCは、昇順ソート
  • を表す.
  • DESCは降順で
  • を表す.
    上はすべて1つのフィールドのソートで、下は2つの
    select * from student order by age ,name desc

    この文は、Studentテーブルを最初のageフィールドでソートし、ageフィールドの昇順ソートが前後しない場合、nameで2回ソートします.ここでnameは降順です.
    select * from st_password order by upper(password)

    これはst_passwordテーブルの下のpasswordは昇順に並べ替えられ、大文字と小文字が区別されます.
    select * from student order by age nulls last

    Studentテーブルの下にageで昇順に並べ替え、nullの値を後ろに置くNULLS FIRSTNULL値より前にNULL値、NULLS LASTNULL値より後にNULL値を配置
     
    ----------------------------------------------------------------------