Oracle merge query transaction SQL function knowledge learning

Source: Internet
Author: User
Oracle merge query transaction SQL function knowledge learning. For more information, see

Oracle merge query transaction SQL function knowledge learning. For more information, see

Table query:
Merge query: Use the union keyword to remove duplicate rows that meet the condition.
The Code is as follows:
Select ename, sal, job from emp where sal> 2500 union select ename, sal, job from emp where job = 'manager ';

Union all is similar to union, but duplicate rows are not canceled.
Intersect is used to obtain the intersection of two results.
Minus is used to obtain the difference set of two results.
Make employee scott's position, salary, and subsidy the same as SMITH's. (Use subquery to modify data)
The Code is as follows:
Update emp set (job, sal, comm) = (select job, sal, comm from emp where ename = 'Smith ') where ename = 'Scott ';

Transaction:
Set save point
Savepoint
Cancel some transactions
Roll back to
Cancel all transactions
Rollback
Set as read-only transaction, used to count the information before a certain moment, and in the statistical process, there may be access, impact statistics, so before the statistics, set as read-only transactions, in this way, the results before the current moment will be saved, and subsequent modifications will not be displayed. The statement for setting as a read-only transaction is:
The Code is as follows:
Set transaction read only;

The transaction processing set is displayed.
SQL functions:
Display the display content in lower case. Use the lower function, for example
The Code is as follows:
Select lower (ename), sal from emp;

The display content is displayed in uppercase and lowercase. The upper function is used as well as the length function and substr function.
The Code is as follows:
Select * from emp where length (ename) = 5;
Select substr (ename, 1, 3) from emp;

Substr indicates that three values are obtained from the first value.
The names of all employees are displayed in uppercase.
Capital employee name
The Code is as follows:
Select upper (sub (ename, 1, 1) from emp;

Lowercase letters after the first letter
The Code is as follows:
select lower(substr(ename,2,length(ename)-1)) from emp;


Then merge the two results to get the content to be displayed:
 

select upper(substr(ename,1,1))||lower(substr(ename,2,length(ename)-1)) as name from emp;


Replace Function
 
Select replace (ename, 'A', 'I') from emp;






 

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.