いろいろな関数

853 ワード

  • 算術関数
  • ABS-絶対値
  • abs(数値)select m,abs (m) as abs_col from ;
  • mod--余
  • を求める
    mod(被残数、除数)
  • round--四捨五入
  • round(オブジェクト、保持する小数の桁数)
  • 文字列関数
  • |--接合
  • str 1‖str 2はmysqlでconcat(文字列、文字列、文字列)
  • length()--文字列の長さ
  • lower()--小文字変換
  • upper()--大文字変換
  • replace(置換に使用する文字列、置換前の文字列、置換後の文字列)--文字列の置換
  • substring(切り取る文字列fromから始まる切り取りバイトfor切り取りバイト数)--文字列切り取り
  • 日付関数
  • current_date--現在の日付
  • select current_date;
  • current_time--現在時刻
  • select current_time;
  • current_timestamp--現在の日付と時刻
  • select current_timestamp;
  • extract(日付要素from日付)--日付要素
  • を切り取ります.
    extract (year from current_timestamp) as year;
  • 変換関数
  • cast(変換前の値as変換したいデータ型)--タイプ変換
  • select cast('0001' as integer) as int_col; 結果は1
  • coalesce(データ1、データ2、データ3、...)--NULLを別の値
  • に変換