Oracle Basic Queries

Source: Internet
Author: User

SELECT * FROM teacher
--female teacher number, name
Select Tno,tname,gendar from teacher where gendar= ' woman '
--Han's female teacher number, name, ID number
Select Tno,tname,tid from teacher where gendar= ' women ' and tname like ' Korean '
--Salary between [10000,20000] teacher List
Select Sal,tname from teacher where Sal between 10000 and 20000
-Post for lecturer or development, sorted by salary in descending order
Select Tname,sal,job from teacher where job in (' Lecturer ', ' research and Development ')
ORDER BY Sal Desc
--INSERT statement for all data in the department
SELECT * FROM Dept
--oracle Use | | To concatenate strings
INSERT INTO Dept values (40, ' Ministry of Manpower ', ' Beijing Haidian ')
--How to query
Select ' INSERT INTO dept values (' | | deptno| | ', ' ' | | dname| | "' | | ', ' | | loc| | ');
From dept;

SELECT * FROM teacher
--Name of all male teachers in admissions department
--Using subqueries
Select Tname,gendar,deptno
From teacher
where deptno= (select Deptno from dept where dname= ' Admissions Department ')
and gendar= ' man '
--Using Inner connection 01
Select Tname,gendar,d.deptno,dname
From teacher T,dept D
where T.deptno=d.deptno
and gendar= ' Male ' and dname= ' admissions Department '

--Using inner connection 02
Select Tname,gendar,d.deptno,dname
From teacher T INNER join dept D
On T.deptno=d.deptno
where gendar= ' male ' and dname= ' admissions Department '

--All teachers ' names, departments
Select Tname,dname
From teacher T,dept D
where T.deptno=d.deptno

--The names of all teachers and the names of their mentors are self-connected
Select T1.tname,t2.tname as tutor name from teacher T1,teacher T2
where T2.tno=t1.mgrno


--All teachers ' names, departments, mentors
Select T.tname as teacher name, T1.tname as tutor name, D.dname as Department
From teacher T left join teacher T1
On T.mgrno=t1.tno
Left JOIN Dept D
On T.deptno=d.deptno

--List all names and dates of birth
Select Tname,birthdate from teacher

Oracle Basic Queries

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.