Database knowledge (mainly based on oracle,sql for reference)

Source: Internet
Author: User

1. Knowledge of Union

Select one from Dualunion select one from dual

And

Select one from Dualunion allselect one from dual

The effect of union is to merge query results all to keep duplicate rows

2. Knowledge of ORDER BY

2.1 Select T.*fromorderby1,2
--Sort By column number

2.2 SelectT.*, T.rowid fromUsers TOrder  byT.name Nulls First
-- This field is preceded by a null value
SelectT.*, T.rowid fromUsers TOrder byT.name Nulls Last
-- This field is followed by a null value row

2.3 Select T.*from thewherein ('admin','  test2',' test ')order by InStr (  'admin,test2, test ', T.name)
--Sort by in order

2.3.1 Select T.*fromorder by InStr (' admin, test2 , Test 'desc
--Sort PS in order: at the bottom of the line. You can adjust the values in the InStr as required

3. About Base64-bit database encryption and decryption knowledge

Select utl_raw.cast_to_varchar2 (Utl_encode.base64_decode (Utl_raw.cast_to_raw ('mteumg==  'as from-- decryption result 11.2
Select utl_raw.cast_to_varchar2 (Utl_encode.base64_encode (Utl_raw.cast_to_raw (11.2from  --mteumg==

4. Oracle MoD uses a number that is divisible by M within n

 SelectT.rnum from(SELECTRowNum Rnum fromAll_objectsWHEREROWNUM<= Ten) TwhereMoD (T.rnum,3)=0 ; --number of results divisible by 3 within 10 3,6,9 Select sum(T.rnum) asTotal_sum from(SELECTRowNum Rnum fromAll_objectsWHEREROWNUM<= Ten) TwhereMoD (T.rnum,3)=0 ; --and results of the numbers divisible by 3 within 10

Usage of 5.Oracle decode

SelectDecode (AA,' One','data is one',' A','data is','Other data') as"Data Results" from(Select  One  asAa fromDualUnion  AllSelect  A  fromDualUnion  AllSelect 221  fromDualUnion  AllSelect 333  fromdual)

Start with usage of 6.Oracle

SelectT.*  fromSys_tree TwhereT.isdel=1Start withT.code=' -'Connect byPrior t.id=T.pidOrder  byT.orderno--Querying all child nodes                        SelectT.*  fromSys_tree TwhereT.isdel=1Start withT.code=' -'Connect byPrior t.pid=t.idOrder  byT.orderno--querying all parent nodes

Database knowledge (mainly based on oracle,sql for reference)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.