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