Oracle Database 12c SQL Fundamentals I Exam Guide Exam 1Z0-061 学习笔记

本文档详细介绍了Oracle Database 12c SQL Fundamentals I Exam 1Z0-061的学习笔记,包括SQL运算符与空值处理、转义字符、LIKE通配符、会话变量、字符串函数TRIM、NLS参数设置、转换函数TO_CHAR、NVL及NVL2函数、NULLIF和COALESCE、CASE表达式、聚合函数计数、平均值、求和、方差和标准差、不同类型的JOIN操作、对象命名规则、数据类型以及创建和修改表的约束。
摘要由CSDN通过智能技术生成
I. any arithmatic operator with null will result null
   concate null will not result in null, will remain the same without null
II, for ' in literal value, could use '' to escape the it.
    or could use q'<conent ''''''>' to use escape the ' in the literal value, here <> could be any other charactors or bracket paris.
--------3-----------
I.Like wildcard symbol, we could use _(for 1 letter) or %(for 0 or more letters)
  to escapse like wildcard, we could use '\%test' escape '\'; in where clause
  
II, for ampersand(&), we could double ampersand(&&) to define a session variable, so we could reuse this value in current session.
    for ampersand, we could use it in select &col_name from rcv_supply;
    for ampersand, we even could use select &rest_statment;
    if use ampersand for literal values and date, we could to use single quotes, like '&t1'
III. for double ampersand, we could define command to define a variable to let it works the same
     define t1= 'test1'      <=>    select col1 from table1 where col1='&&t1' or col2 = '&t1';
IV undefine could use to clear the variable we defined.
   verify could use to show the value of defined variable while actually running the scripts.

--------------4------------------
TRIM([trailing|leading|both] trimstring from s),
The string to be trimmed (s) is mandatory. The following points list the rules governing the use of this function:
image  TRIM(s) removes spaces from both sides of the input string. When no direction of trimming is specified, then spaces are trimmed from both sides of the string.
image  TRIM(trailing trimstring from s) removes all occurrences of trimstring from the end of the string s if it is present.
image  TRIM(leading trimstring from s) removes all occurrences of trimstring from the beginning of the string s if it is present.
image  TRIM(both trimstring from s) removes all occurrences of trimstring from the beginning and end of the string s if it is present.
SELECT TRIM('aababcca'), TRIM(leading 'a' from 'aababcca'), TRIM(trailing 'a' from 'aababcca'), TRIM(both 'a' from 'aababcca')   from dual;
aababcca babcca aababcc babcc
  
-------------------5---------------
nls_parameter always is omitted, and we could use the following command to alter it in session
alter session set nls_currency='USD';
TO_CHAR(number1, [format], [nls_parameter])
The TO_CHAR function, fm modifier, and the sp, th, and spth format models are commonly examined. 


Format Element  Description and Format Mask                         Result
fm              remove relevant space                               select to_char(sysdate, 'fmMonth')||'123' from dual; return 'May123'; If don't use fm, it returns 'May      123'; it Month by default return 9 letters.
TH              Positional or ordinal text:'DDth''of'' Month'       12th of September
SP              Spelled out number: 'MmSP Month Yyyysp'             Nine September Two Thousand Eight
THSP or SPTH    Spelled out positional or ordinal number:'hh24SPTh' Fourteenth


1.NVL(original, ifnull); -- if original is null, then return ifnull expression;
2.NVL2(original, ifnotnull, ifnull); --if orignal is not null, return ifnotnull expression; or else, return ifnull expression;
  ifnotnull and ifnull should have the same data type(or could convert ifnull to same data type as ifnotnull implicitly, nvl2(1, 'a', 4) is valid, nvl2(2, 4, 'a') is invalid.
3.NULLIF(ifunequal, comparison_term);--if ifunequal expression is equals with comparison_term, return null; or else return ifunequal.
4.COALESCE(expr1, expr2,…,exprn); --return the 1st non-null parameter; if all parameters are null, return null; it takes 2 mandatory parameters, and any number of optional parameters 
   all parameters should be the same data type, coalesce(1234, '1',4) is invalid
5.DECODE(expr1,comp1, iftrue1, [comp2,iftrue2…[compN,iftrueN]], [iffalse])
  -- decode function, at least 3 parameters are mandatory.  If the iffalse parameter does not exist and no matches are found, a null value is returned.
  -- decode(1, 1, 3, 'a') is invalid, and will throw exception; but decode(1,1,3, 'a') is valid, since 'a' will never be executed;
  -- all iftruex expression are expected the same data type as iftrue1(or cou
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值