oracle資料庫員工表查詢

2021-07-24 23:38:57 字數 1571 閱讀 9162

孟子辰

2016-11-28 10:13

1、請從表emp中查詢工種是職員clerk或經理manager的雇員姓名、工資。

select ename,sal from emp where job='clerk' or job='manager';

2、請在emp表中查詢部門號在10-30之間的雇員的姓名、部門號、工資、工作。

select ename,deptno,sal,job from emp where deptno between 10 and 30;

3、請從表emp中查詢姓名以j開頭所有雇員的姓名、工資、職位。

select ename,sal,job from emp where ename like 'j%';

4、請從表emp中查詢工資低於2000的雇員的姓名、工作、工資,並按工資降序排列。

select ename,job,sal from emp where sal<=2000 order by sal desc;

5、請從表中查詢工作是clerk的所有人的姓名、工資、部門號、部門名稱以及部門位址的資訊。

select ename,sal,emp.deptno,dname,loc from emp,dept where emp.deptno=dept.deptno and job=』clerk』;

6、查詢表emp中所有的工資大於等於2000的雇員姓名和他的經理的名字。

select a.ename,b.ename from emp a,emp b where a.mgr=b.empno(+) and a.sal>=2000;

7、查詢所有雇員的姓名、sal與comm之和。

select ename,sal+nvl(comm,0) 「sal-and-comm」 from emp;

8、查詢所有81年7月1日以前來的員工姓名、工資、所屬部門的名字

select ename,sal,dname from emp,dept where emp.deptno=dept.deptno and hiredate<=to_date(『1981-07-01』,』yyyy-mm-dd』);

9、查詢列出來公司就職時間超過24年的員工名單

select ename from emp where hiredate<=add_months(sysdate,-288);

10、查詢於81年來公司所有員工的總收入(sal和comm)

select sum(sal+nvl(comm,0)) from emp where to_char(hiredate,』yyyy』)=』1981』;

11、查詢顯示每個雇員加入公司的準確時間,按××××年××月××日 時分秒顯示。

select ename,to_char(hiredate,'yyyy-mm-dd hh24:mi:ss') from emp;

12、查詢列出各部門的部門名和部門經理名字

oracle 資料庫表結構查詢

oracle查詢使用者所有表的語句 select from all tab comments 查詢所有使用者的表,檢視等 select from user tab comments 查詢本使用者的表,檢視等 select from all col comments 查詢所有使用者的表的列名和注釋.s...

資料庫 oracle查詢表資訊

修改資料庫中一張表指定欄位的資料,該字段在其他表中也存在,需要同步修改 此時需要統計資料庫中所有包含該字段的表。獲取表字段 select from user tab columns where table name 使用者表 獲取表注釋 select from user tab comments w...

Oracle資料庫 查詢所有表

1.查詢當前資料庫下的所有表 select from all tables where owner test 注 all tables查出來是查得所有使用者下的表,當然也包括你登入的用下的表,然後加乙個where你要查的那個使用者名稱就可以了。記得使用者名稱要大寫 2.查詢當前資料庫下某個例項資料庫...