Common Query operations in Oracle

Source: Internet
Author: User

General Query:
select * from T;


To remove duplicate values:
Select distinct f1,f2 from T;


Between usage:
SELECT * FROM t where F1 not/between 1and 2;


Like usage:
SELECT * FROM t where F1 not/like ' _mdb% ';


In usage:
SELECT * FROM t where F1 not/in (n1,n2.);


Show the first 5 lines:
SELECT * FROM t where rownum<=5;


Sequential/reverse order:
SELECT * FROM-t order by F1,F2 Asc/desc;


Sum by field:
Select SUM (F2) from T1 GROUP by F1;
When federating multiple tables, use having to replace where:
Having AVG (F1) >50;


Combine two columns to display:
Select F1| | ': ' | | F2 as F12 from T;


To back up table data:
CREATE TABLE t2 as select * from T1;


To insert data from another table:
INSERT INTO T2 select * from T2;


To find an average of a column:
Select AVG (F1) from T1;


To find the number of rows:
Select COUNT (*/f1) from T1;


Maximum/Minimum Value:
Select Max/min (F1) from T1;


Floating-point data rounding:
Select Round (f5,2) from T1;


Data entry:
Select *from T1 inner/left/right/full join T2 on T1.F1=T2.F2;


Data Federation (the two table columns need to be the same):
Select F1,f4 FROMT1 Union select f1,f2 from T2;


Data interception:
Select substr (f1,1,3) from T1;
Update T1 set F1=SUBSTR (f2,1,3) | | ' Say ' | | SUBSTR (f3,7);

Common Query operations in Oracle

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.