(iii) Oracle Learning NOTE--SQL statement

Source: Internet
Author: User
Tags dname

0. The Scott User default table describes

Scott user tables directory contains four tables

1. Insert (INSERT) statement

To insert data into a specified column:

Insert  into Values ("xx");

Insert all column data:

Insert  into Values (x,'xx','lll');

2. Update (UPDATED) statement

UpdateDeptSetDname='Ministry of Justice' whereDeptno= -;UpdateDeptSetDname='Ministry of Justice', loc=' China' whereDeptno= -;

3. Delete (delete) statement

To delete the specified data:

Delete  from where deptno=;

Delete data for the specified condition:

Delete  from where deptno>;

4. Select (query) statements

Check all:

Select *  from EMP;

To specify a field query:

Select  from EMP;

Shorthand

Insert  into Values (+,'xxx','llll');

Add where condition:

Select *  from where sal>=; Select *  from where sal>= and job='salesman ';

Distinct to repeat the record;

Group by Group query:select Job,count (ename) as Num from EMP T GROUP by Job;

having Filter Group:Select Job,count (ename) as Num from EMP T GROUP by Job have count (ename) >=2;

Order by Sort:select * from emp order BY Sal Desc;

subquery: Query for employees with base pay greater than average salary: SELECT * from emp where sal> (select AVG (SAL) from EMP)

Federated query:

and set (to repeat):

Select *  from T_user1 Union Select *  from T_user2;

and set:

Select *  from T_user1 Union  All Select *  from T_user2;

Intersection:

Select *  from T_user1 intersect Select *  from T_user2;

Subtraction

Select *  from T_user1minus Select *  from T_user2;

Internal connection:

SELECT * from emp t,dept d where T.deptno=d.deptno;

Similar to: SELECT * from EMP e inner joins dept D on E.deptno=d.deptno; Inner can be omitted;

External connection:

Left outer connection: SELECT * from emp e ieft join dept D on E.deptno=d.deptno;

Right outer connection: SELECT * from emp e starboard Join Dept D on E.deptno=d.deptno;

(iii) Oracle Learning NOTE--SQL statement

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.