Oracle instances, specifically using

Source: Internet
Author: User

Use of Oracle Keywords

Use Insert to add data: INSERT into table name VALUES (add corresponding number); COMMIT;

INSERT into P_emp

VALUES (' TOM2 ', ' clerk ', 7902, Sysdate,, NULL, 30);

COMMIT;

Try delete Delete a data: Delete table name WHERE condition; COMMIT;

DELETE p_emp e WHERE e.empno=1;

COMMIT;

Use Update to modify data: Update table name SET Modify the content WHERE condition; COMMIT;

UPDATE p_emp e SET e.ename= ' TOM3 ' WHERE e.empno=2;

COMMIT;

In keyword, query for data that conforms to the in condition. Example: Query employee information for payroll 800,3000,5000

SELECT * from P_emp e WHERE e.sal in (800, 3000, 5000);

Like keyword, fuzzy query,% denotes any character, _ represents a single character. Example: Query the employee's information that starts with T

SELECT * from P_emp e WHERE e.ename like ' t% '

Order BY, sort by column name or index

SELECT * from P_emp e ORDER by e.job desc, e.sal desc

SELECT * from P_emp e ORDER by 3, 6

Group BY is grouped by a few columns

SELECT e.job from P_emp e GROUP by E.job have COUNT (*) > 2

Using the Sum,avg,mod,count function

SELECT P.toma,p.ptype,sum (P.lastcou) from product P GROUP by ROLLUP (P.toma,p.type)

Use of case when Then/decode

Case * When condition then display content

DECODE (*, ' condition ', ' show content ')

SELECT T.ename,

Case T.sex If 1 then ' Male ' when 0 Then ' women ' ELSE ' KK ' END

From P_emp T

SELECT t.ename Name,

case if T.sex = 1 Then ' male ' when t.sex = 0 Then ' women ' ELSE ' KK '

END Sex

From P_emp T

Distinct removing duplicates

SELECT DISTINCT t.job from P_emp t

Between A and b between A and B

SELECT * from P_emp t WHERE t.sal between and 3000

Oracle instances, specifically using

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.