zoukankan      html  css  js  c++  java
  • Oracle基础学习四:字符串 数字 日期 等 相关函数

    以下内容摘自
    Oracle PL/SQL Programming(By Steven Feuerstein, Bill Pribyl)
    本人并没有逐个学习每个函数的功能及其用法
    有兴趣或有用到的话  请自行掌握

    A. String
    B. Number
    C. Dates and Times
    =========================

    A. String :
    ===========
    01. ASCII(single_character)
    02. ASCIISTR(string1)
    03. CHR(code_location)
    04. COMPOSE(string1)
    05. CONCAT(string1, string2)
    06. CONVERT(string1, target_char_set)
    07. DECOMPOSE(string1)
    08. GREATEST(string1, string2, ...)
    09. INITCAP(string1)
    10. INSTR(string1, string2)
    11. LEAST(string1, string2, ...)
    12. LENGTH(string1)
    13. LOWER(string1)
    14. LPAD(string1, padded_length)
    15. LTRIM(string1)
    16. NCHR(code_location)
    17. NLS_INITCAP(string1)
    18. NLS_LOWER(string1) and NLS_LOWER(string1, 'NLS_SORT=sort_sequence_name')
    19. NLS_UPPER(string1) and NLS_UPPER(string1, 'NLS_SORT=sort_sequence_name')
    20. NLSSORT(string1) and NLSSORT(string1, 'NLS_SORT=sort_sequence_name')
    21. REPLACE(string1, match_string, replace_string)
    22. RPAD(string1, padded_length)
    23. RTRIM(string1)
    24. SOUNDEX(string1)
    25. SUBSTR(string1, start, length)
    26. TO_CHAR(national_character_data)
    27. TO_MULTI_BYTE(string1)
    28. TO_NCHAR(database_character_data)
    29. TO_SINGLE_BYTE(string1)
    30. TRANSLATE (string1, search_set, replace_set)
    31. TRANSLATE(text USING CHAR_CS) and TRANSLATE(text USING NCHAR_CS)
    32. TRIM (FROM string1)
    33. UNISTR(string1)
    34. UPPER(string1)

    示例
    SQL> SELECT LENGTH(TRIM('AAA   ')) VALUE FROM DUAL
      2  ;

         VALUE
    ----------
             3

    ===========
    B. Number :
    ===========
    01. ABS(n)
    02. ACOS(n)
    03. ASIN(n)
    04. ATAN(n)
    05. ATAN2(n, m)
    06. BIN_TO_NUM(b1, b2,...bn)
    07. BITAND(n, m)
    08. CEIL(n)
    09. COS(n)
    10. COSH(n)
    11. EXP(n)
    12. FLOOR(n)
    13. GREATEST(n1, n2,...n3)
    14. LEAST(n1, n2,...n3)
    15. LN(n)
    16. LOG(b, n)
    17. MOD(n, m)
    18. NANVL(n, m)
    19. POWER(n, m)
    20. REMAINDER(n, m)
    21. ROUND(n)
    22. ROUND(n, m)
    23. SIGN(n)
    24. SIN(n)
    25. SINH(n)
    26. SQRT(n)
    27. TAN(n)
    28. TANH(n)
    29. TRUNC(n)
    30. TRUNC(n, m)

    示例
    SQL> SELECT POWER(4,2) AS VALUE FROM DUAL;

         VALUE
    ----------
            16

    ====================
    C. Dates and Times :
    ====================
    01. ADD_MONTHS
    02. CAST
    03. CURRENT_DATE
    04. CURRENT_TIMESTAMP
    05. DBTIMEZONE
    06. EXTRACT
    07. FROM_TZ
    08. LAST_DAY
    09. LOCALTIMESTAMP
    10. MONTHS_ BETWEEN
    11. NEW_TIME
    12. NEXT_DAY
    13. NUMTODSINTERVAL
    14. NUMTOYMINTERAL
    15. ROUND
    16. SESSIONTIMEZONE
    17. SYSDATE
    18. SYS_EXTRACT_UTC
    19. SYSTIMESTAMP
    20. TO_CHAR
    21. TO_DATE
    22. TO_DSINTERVAL
    23. TO_TIMESTAMP
    24. TO_TIMESTAMP_TZ
    26. TO_YMINTERVAL
    27. TRUNC
    28. TZ_OFFSET

    示例
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2         current_date DATE;
      3         next_month DATE;
      4      BEGIN
      5         current_date := SYSDATE;
      6         next_month := ADD_MONTHS(current_date, 1);
      7         DBMS_OUTPUT.PUT_LINE(next_month);
      8      END;
      9  /
    16-5月 -07

    PL/SQL 过程已成功完成。
    -----------------------------------


    EXTRACT (component_name, FROM {datetime | interval})

    Datetime component names for use with EXTRACT
    01. YEAR
    02. MONTH
    03. DAY
    04. HOUR
    05. MINUTE
    06. SECOND
    07. TIMEZONE_HOUR
    08. TIMEZONE_MINUTE
    09. TIMEZONE_REGION
    10. TIMEZONE_ABBR

    示例
    SQL> BEGIN
      2         IF EXTRACT (MONTH FROM SYSDATE) = 11 THEN
      3            DBMS_OUTPUT.PUT_LINE('It is November');
      4         ELSE
      5            DBMS_OUTPUT.PUT_LINE('It is not November');
      6         END IF;
      7      END;
      8  /
    It is not November

    PL/SQL 过程已成功完成。

  • 相关阅读:
    新入住CNBLOG
    C#简易外挂制作
    Cnblogs自定义皮肤css样式简易设定
    ACFUNProject{网页通用筛选抓取器+C#初学者简易教程}
    Java Collectors API实践
    下单延迟10s撤单性能测试
    Go WebSocket开发与测试实践【gorilla/websocket】
    复杂JSON结构创建语法
    单元测试再出发
    动态模型之动态增减【FunTester测试框架】
  • 原文地址:https://www.cnblogs.com/freeliver54/p/716191.html
Copyright © 2011-2022 走看看