Oracle的sql语句
来源:互联网 发布:中国近现代报刊数据库 编辑:程序博客网 时间:2024/05/21 22:22
登录方法:
1.运行-》cmd
2.输入sqlplus /nolog
3.先以管理员的身份登录,oracle的默认的用户别锁着。SQL>connect / as sysdba ;
4.解锁。alter user [username] account unlock;
5.修改密码alter user [username] identified by [password];
sql语句语法:
使用scott/tiger用户下的emp表和dept表完成下列练习,表的结构说明如下
emp员工表(empno员工号/ename员工姓名/job工作/mgr上级编号/hiredate受雇日期/sal薪金/comm佣金/deptno部门编号)
dept部门表(deptno部门编号/dname部门名称/loc地点)
工资 = 薪金 + 佣金
------1.列出至少有一个员工的所有部门
select * from dept
where deptno in
(select deptno from emp group by deptno having count(*)>1);
------2.列出薪金比“SMITH”多的所有员工。
select * from emp
where sal>(select sal from emp where ename='SMITH');
------3.列出所有“CLERK”(办事员)的姓名及其部门名称。
select dname,ename from dept a,emp b
where a.deptno=b.deptno and job='CLERK';
select (select dname from dept where deptno=a.deptno) as dname ,ename
from emp a
where job='CLERK';
------4.列出最低薪金大于1500的各种工作。
select job,min(sal) msal from emp
group by job having min(sal)>1500;
------5.列出薪金高于公司平均薪金的所有员工。
select ename from emp where sal>(select avg(sal) from emp);
------6.列出在部门“SALES”(销售部)工作的员工的姓名,假定不知道销售部的部门编号。
select ename from emp where deptno=(select deptno from dept where dname='SALES');
------7.列出与“SCOTT”从事相同工作的所有员工。
select * from emp where job=(select job from emp where ename='SCOTT');
------8.列出薪金等于部门30中员工的薪金的所有员工的姓名和薪金。
select * from emp where sal in
(select sal from emp where deptno=30);
或
select * from emp where sal = any
(select sal from emp where deptno=30);
------9.列出所有员工的姓名、部门名称和工资。
select ename,dname,sal+nvl(comm,0) from emp,dept where emp.deptno=dept.deptno;
------10.列出薪金高于在部门30工作的所有员工的薪金的员工姓名和薪金。
--最大值>all
select * from emp where sal>all
(select sal from emp where deptno=30);
--最小值<all
select * from emp where sal < all
(select sal from emp where deptno=30);
------11.列出MANAGER(经理)的最低薪金。
select min(sal) from emp where job='MANAGER' ;
------12.列出所有员工的年工资,按年薪从低到高排序。
select ename,(sal+nvl(comm,0))*12 tot from emp order by tot;
总结
- oracle sql 的语句
- Oracle的sql语句
- oracle sql的语句
- Oracle常用的SQL语句
- Oracle的翻页Sql语句
- Oracle 有用的SQL语句
- Oracle的翻页Sql语句
- Oracle的翻页Sql语句
- Oracle 有用的SQL语句
- Oracle的sql语句优化
- Oracle SQL 语句的优化
- Oracle分页的SQL语句
- oracle sql语句的优化
- SQL语句的优化(Oracle)
- oracle的常用sql语句
- oracle常用的SQL语句
- ORACLE的SQL语句练习
- oracle常用的sql语句
- 一些有用的dos命令
- listCtrl控件构造函数中用InsertColumn初始化 错误分析
- 再次感受vim的强大 || tap 键 设置
- SQL基础
- ExtJS 自定义事件学习
- Oracle的sql语句
- VS2005/2008问题之——由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题
- Java设计模式—singleton 单例
- TheTechBehindDx11UnrealEngine"Samaritan"Demo
- Oracle 数据库笔记2
- 超市数据上传与下载的解决方案
- Android培训班(43)
- struts2 crud
- VC++中CList使用