>

oracle数据库导入

- 编辑:澳门新葡亰平台游戏 -

oracle数据库导入

Web_THBC 为表示层也就是页面 BLL_THBC 为业务逻辑层 DAL_THBC 为数据库交互层 Model_THBC 为实体类 DbHelper 为数据库连接类 统计个专营店的男女数量 复制代码 代码如下: select dua.UARTERS_ID,dua.UARTERS_NAME ,sum(case when sex = '1' then 1 else 0 end) as Man ,sum(case when sex = '0' then 1 else 0 end) as Woman from dbo.DCAD_USER as du left join dbo.DCAD_UARTERS as dua on du.UARTERS_ID = dua.UARTERS_ID group by dua.UARTERS_ID,dua.UARTERS_NAME 作者 ershouyage

select empno, ename, to_char(hiredate, 'yyyy-mm-dd') from emp;

完成后,system的密码为system

select e.ename, e.sal, d.dname, decode(s.grade, 1, '第五等级', 2, '第四等级', 3, '第三等级', 4, '第二等级', 5, '第一等级'), m.ename, m.sal, decode(ms.grade, 1, '第五等级', 2, '第四等级', 3, '第三等级', 4, '第二等级', 5, '第一等级')from emp e, dept d, salgrade s, emp m, salgrade mswhere e.deptno = d.deptno and e.sal between s.losal and s.hisal and e.mgr = m.empnoand m.sal between ms.losal and ms.hisal;

以上所述是小编给大家介绍的oracle数据库导入.dmp脚本的sql 语句,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

  1. select * from emp;

  2. select empno, ename, job from emp;

  3. select empno 编号, ename 姓名, job 工作 from emp;

  4. select job from emp;

  5. select distinct job from emp;

  6. select distinct empno, job from emp;说明:因为雇员编号不重复, 所以此时证明所有的列没有重复,所以不能消除掉重复的列.

  7. 查询出雇员的编号, 姓名, 工作, 但是显示的格式:编号是: 7369 的雇员, 姓名是: smith, 工作是: clearselect '编号是: ' || empno || '的雇员, 姓名是: ' || ename || ', 工作是: ' || job from emp;

  8. 求出每个雇员的姓名及年薪select ename, sal * 12 income from emp;

  9. 求出工资大于 1500 的所有雇员信息select * from emp where sal > 1500;

  10. 查询每月可以得到奖金的雇员信息select * from emp where comm is not null;

  11. 查询没有奖金的雇员信息select * from emp where comm is null;

  12. 查询出基本工资大于 1500 同时可以领取奖金的雇员信息select * from emp where sal > 1500 and comm is not null;

  13. 查询出基本工资大于 1500 或者可以领取奖金的雇员信息select * from emp where sal > 1500 or comm is not null;

  14. 查询出基本工资不大于 1500 或者不可以领取奖金的雇员信息select * from emp where not(sal > 1500 and comm is not null);

  15. 查询基本工资大于 1500, 但是小于 3000 的全部雇员信息select * from emp where sal > 1500 and sal < 3000;

  16. 查询基本工资大于等于 1500, 但是小于等于 3000 的全部雇员信息select * from emp where sal >= 1500 and sal <= 3000;select * from emp where sal between 1500 and 3000;

  17. 查询出在 1981 年雇佣的全部雇员信息(1981 年 1 月 1 日 到 1981 年 12 月 31 日之间的雇佣的雇员)select * from emp where hiredate between '1-1月-81' and '31-12月-81';

  18. 要求查询出姓名是 smith 的雇员信息select * from emp where ename = 'SMITH';

  19. 要求查询出雇员是 7369, 7499, 7521 的雇员的具体信息select * from emp where empno = 7369 or empno = 7499 or empno = 7521;select * from emp where empno in;

  20. 要求查询出雇员不是 7369, 7499, 7521 的雇员的具体信息select * from emp where empno not in;

  21. 要求查询出姓名是 smith, allen, king 的雇员信息select * from emp where ename in('SMITH', 'ALLEN', 'KING');

  22. 查询出所有雇员姓名中第二个字母包含 "M" 的雇员信息 select * from emp where ename like '_M%';

  23. 查询出雇员姓名中包含字母 M 的雇员信息select * from emp where ename like '%M%';

  24. 要求查询出在 1981 年雇佣的雇员信息select * from emp where hiredate like '%81%';

  25. 查询工资中包含 5 的雇员信息select * from emp where sal like '%5%';

  26. 查询雇员编号不是 7369 的雇员信息select * from emp where empno != 7369;select * from emp where empno <> 7369;

  27. 要求按照工资由低到高排序select * frm emp order by sal;select * from emp order by sal asc;

  28. 要求按照工资由高到低排序select * from emp order by sal desc;

  29. 要求查询出 20 部门的所有雇员信息, 查询的信息按照工资由高到低排序,如果工资相等,则按照雇佣日期由早到晚排序.select * from emp where deptno = 20 order by sal desc, hiredate asc;

  30. 将小写字母变为大写字母select upper from dual;

  31. 将大写字母变为小写字母select lower from dual;

  32. 要求查询出姓名是 smith 的雇员信息select * from emp where ename = upper;

  33. 使用 initcap() 函数将单词的第一个字母大写select initcap from dual;

  34. 将雇员表中的雇员姓名变为开头字母大写select initcap from emp;

  35. 将字符串 "hello" 和 "world" 进行串联select concat from dual;

  36. 对字符串进行操作的常用字符处理函数select substr 截取字符串, length 字符串的长度, replace 字符串替换 from dual;select substr 截取字符串, length 字符串的长度, replace 字符串替换 from dual;

  37. 显示所有雇员的姓名及姓名的后三个字符select ename, substr -2) from emp;select ename, substr from emp;

  38. 使用数值函数执行四舍五入操作select round from dual;

  39. 要求将 789.536 数值保留两位小数select round from dual;

  40. 要求将 789.536 数值中的整数的十位进行四舍五入进位select round from dual;

  41. 采用 trunc() 函数不会保留任何小数,而且小数点也不会执行四舍五入的操作select trunc from dual;

  42. 通过 trunc() 也可以指定小数点的保留位数select trunc from dual;

  43. 作用负数表示位数select trunc from dual;

  44. 使用 mod() 函数可以进行取余的操作select mod from dual;

  45. 显示 10 部门雇员进入公司的星期数(当前日期 - 雇佣日期 = 天数 / 7 = 星期数)select empno, ename, round / 7) from emp where deptno = 10;

  46. 日期函数months_between(): 求出给定日期范围的月数add_months(): 在指定的日期上加上指定的月数, 求出之后的日期next_day(): 指定日期的下一个日期last_day(): 求出给定日期当月的最后一天日期

  47. select empno, ename, months_between from emp;select empno, ename, round(months_between from emp;

  48. select sysdate, add_months from dual;

  49. select next_day from dual;

  50. select last_day from dual;

  51. 转换函数to_char: 转换成数字to_date(): 转换成日期

  52. 查询所有雇员的雇员编号, 姓名, 雇佣日期select empno, ename,to_char year,to_char months,to_char dayfrom emp;

总结

select empno, ename, to_char(hiredate, 'fmyyyy-mm-dd') from emp;

7、远程导出oracle数据库

  1. 要求显示出平均工资大于 2000 的部门编号和平均工资select deptno, avg from emp group by deptno having avg > 2000;

exp 用户名/密码@远程oralce数据库的IP:端口号/实例 file=存放位置:文件名.dmp full = y;

select d.deptno, temp.dname, temp.c, temp.a, e.ename, e.salfrom (select d.dname , count c, avg mfrom emp e, dept dwhere e.deptno = d.deptnogroup by d.dname) temp, emp e,dept dwhere temp.m = e.saland temp.dname = d.dname;

3、输入:sqlplus /nolog

84. 显示非销售人员工作名称以及从事同一工作雇员的月工资的总和,并且要满足从事同一工作的雇员的月工资合计大于 5000, 输出结果按月工资的合计升序排序.select job, sum su from emp where job <> 'SALESMAN' group by job having sum > 5000 order by su;

一、更改数据库管理员sys/system密码

  1. select empno, ename, d.deptno, dname, loc from emp e, dept d where e.deptno = d.deptno; select empno, ename, d.deptno, dname, loc from emp e inner join dept d on e.deptno = d.deptno;

  2. 左外连接 select empno, ename, d.deptno, dname, loc from emp e, dept d where e.deptno = d.deptno; select empno, ename, d.deptno, dname, loc from emp e left outer join dept d on e.deptno = d.deptno; select empno, ename, d.deptno, dname, loc from emp e left join dept d on e.deptno = d.deptno;

  3. 右外连接 select empno, ename, d.deptno, dname, loc from emp e, dept d where e.deptno = d.deptno; select empno, ename, d.deptno, dname, loc from emp e right outer join dept d on e.deptno = d.deptno; select empno, ename, d.deptno, dname, loc from emp e right join dept d on e.deptno = d.deptno;

  4. select e.empno, e.ename, m.empno, m.ename from emp e, emp m where e.mgr = m.empno;

  5. select e.empno, e.ename, m.empno, m.ename from emp e, emp m where e.mgr = m.empno;

  6. select * from emp e, dept d where e.deptno = d.deptno and d.deptno = 30;select * from emp e inner join dept d on e.deptno = d.deptno where d.deptno = 30;select * from emp e join dept d on e.deptno = d.deptno where d.deptno = 30;select * from emp e natural join dept d where deptno = 30;select * from emp e join dept d using where deptno = 30;

  7. select e.ename, d.deptno, d.dname, d.loc from emp e right outer join dept d on e.deptno = d.deptno;select e.ename, d.deptno, d.dname, d.loc from emp e right join dept d on e.deptno = d.deptno;select e.ename, d.deptno, d.dname, d.loc from emp e, dept d where e.deptno = d.deptno;

  8. select count from emp;

  9. select min from emp;

  10. select max from emp;

  11. select sum from emp;

  12. select avg from emp;

  13. select sum from emp where deptno = 20;

  14. select avg from emp where deptno = 20;

  15. 求出每个部门的雇员数量select deptno, count from emp group by deptno;select deptno, count from emp group by deptno;

  16. 求出每个部门的平均工资select deptno, avg from emp group by deptno;

  17. 按部门分组, 并显示部门的名称, 及每个部门的员工数select d.dname, count from emp e, dept d where e.deptno = d.deptnogroup by d.dname;

6、输入:altre user system identified by system

select d.deptno, d.dname, temp.cfrom (select deptno, count c from emp e group by e.deptno) temp, dept dwhere temp.deptno = d.deptno;

create tablespace bjshelldb datafile 'D:appAdministratororadataorclbjshell01.dbf' size 3000M autoextend on;

create user BJSHELL identified by 111111 default tablespace bjshelldb;

grant connect,resource,create view to BJSHELL; grant dba to BJSHELL;grant imp_full_database to BJSHELL;grant connect,resource to BJSHELL;

imp BJSHELL/111111 file=E:dbCRM-20160921.dmp log=E:dbCRM-20160921.log buffer=8000000 commit=y full=y

drop user BJSHELL cascade;

DROP TABLESPACE bjshelldb INCLUDING CONTENTS AND DATAFILES;

select temp.job, sum sfrom (select job, sal from emp e where job <> 'SALESMAN') tempgroup by temp.jobhaving sum > 5000order by s;

二、导入数据库

  1. 求出平均工资最高的部门工资select max from emp group by deptno;

  2. 要求查询出比雇员编号为 7654 工资高的所有雇员信息select * from emp where sal >(select sal from emp where empno = 7654);

  3. 要求查询出工资比 7654 高, 同时与 7788 从事相同工作的全部雇员信息select * from emp where sal >(select sal from emp where empno = 7654)and job = (select job from emp where empno = 7788);

  4. 要求查询出工资最低的雇员姓名, 工作, 工资select ename, job, sal from emp where sal = from emp);

  5. 要求查询出: 部门名称,部门的员工数,部门的平均工资,部门的最低收入雇员的姓名select d.dname, temp.c, temp.a, e.ename from dept d, (select deptno, count a, min m from emp group by deptno) temp, emp ewhere d.deptno = temp.deptno and e.sal = temp.m;

2、输入:SET ORACLE_SID = 你的SID名称

  1. 查询所有雇员的编号, 姓名和工资select empno, ename, sal from emp;select empno, ename, to_char from emp;select empno, ename, to_char from emp;select empno, ename, to_char from emp;

  2. select to_number + to_number from dual;

  3. 将一个字符串转换成日期类型select to_date('2009-01-01', 'yyyy-mm-dd') from dual;

  4. 求出每个雇员的年薪select empno, ename, sal, comm, * 12 from emp;select empno, ename, sal, comm, nvl, * 12 income from emp;

  5. decode() 函数类似于 if....elsif...else 语句select decode(1, 1, '内容是 1', 2, '内容是 2', 3, '内容是 3') from dual;

  6. 查询出雇员的编号, 姓名, 雇佣日期及工作, 要求将雇员的工作替换成以下信息:select empno 雇员编号, ename 雇员姓名, hiredate 雇佣日期, decode(job, 'CLERK', '业务员', 'SALESMAN', '销售人员','MANAGER', '经理','ANALYST', '分析员','PRESIDENT', '总裁') 职位from emp;

  7. 笛卡尔积select * from emp, dept;select * from emp cross join dept;

  8. 内连接select * from emp e, dept d where e.deptno = d.deptno;select * from emp e inner join dept d on e.deptno = d.deptno;select * from emp e join dept d on e.deptno = d.deptno;

  9. 自然连接select * from emp natural join dept;select * from emp e join dept d using;

  10. 要求查询出雇员的编号, 姓名, 部门的编号, 名称, 地址select e.empno, e.ename, d.deptno, d.dname, d.loc from emp e, dept d where e.deptno = d.deptno;

  11. 要求查询出雇员的姓名, 工作, 雇员的直接上级领导姓名select e.ename, e.job, m.ename from emp e, emp m where e.mgr = m.empno;

  12. 要求查询出雇员的姓名, 工作, 雇员的直接上级领导姓名以及部门名称select e.ename, e.job, m.ename, d.dname from emp e, emp m, dept d where e.mgr = m.empno and e.deptno = d.deptno;

  13. 要求查询出每个雇员的姓名, 工资, 部门名称, 工资在公司的等级, 及其领导的姓名及工资所在公司的等级select e.ename, e.sal, d.dname, s.grade, m.ename, m.sal, ms.gradefrom emp e, dept d, salgrade s, emp m, salgrade mswhere e.deptno = d.deptno and e.sal between s.losal and s.hisal and e.mgr = m.empnoand m.sal between ms.losal and ms.hisal;

4、输入:connect /as sysdba

  1. 求出每个部门的最低工资的雇员的信息select * from emp where sal in from emp group by deptno);select * from emp where sal =any from emp group by deptno);select * from m from emp group by deptno) temp,emp ewhere e.sal = temp.m;

  2. 范例 90 中, 比子查询条件中最低的工资要大的雇员信息select * from emp where sal >any from emp group by deptno);select * from emp where sal > from emp group by deptno);

  3. 范例 90 中, 比子查询条件中最高的工资要小的雇员信息select * from emp where sal

  4. 范例 90 中, 比子查询条件中最高的工资要大的雇员信息select * from emp where sal >all from emp group by deptno);select * from emp where sal > from emp group by deptno);

  5. 范例 90 中, 比子查询条件中最低的工资要小的雇员信息select * from emp where sal

  6. 查找出 20 部门中没有奖金的雇员信息select * from emp where in (select sal, nvl from emp where deptno = 20);select * from emp where deptno = 20 and comm is null;

  7. union 操作符返回两个查询选定的所有不重复的行select deptno from emp union select deptno from dept;

  8. union all 操作符合并两个查询选定的所有行,包括重复的行select deptno from emp union all select deptno from dept;

  9. intersect 操作符只返回两个查询都有的行select deptno from emp intersect select deptno from dept;

  10. minus 操作符只返回由第一个查询选定但是没有被第二个查询选定的行, 也就是在第一个查询结果中排除在第二个查询结果中出现的行select deptno from dept minus select deptno from emp;

5、输入:altre user sys identified by sys

本文由数据库发布,转载请注明来源:oracle数据库导入