始创于2000年 股票代码:831685
咨询热线:0371-60135900 注册有礼 登录
  • 挂牌上市企业
  • 60秒人工响应
  • 99.99%连通率
  • 7*24h人工
  • 故障100倍补偿
您的位置: 网站首页 > 帮助中心>文章内容

Oracle_5 ROWNUM Create New User 备份一张表

发布时间:  2012/9/16 15:42:50

Rownum是Oracle为每个表附加的一个尾字段,它记录着每一行的行号。Oracle的一个缺陷就是rownum只能和’<’或者’<=’一起使用。如果要求大于等于这可用其他方法。

求薪水最高的前5名

select ename,sal
from ( select ename,sal
from emp
order by sal desc)-
 

where rownum <=5;

求薪水的第6至第10位的员工姓名和薪水

select ename,sal
from ( select ename,sal,rownum r
       from (select ename,sal
             from emp
             order by sal desc)
     )
where r<=10 and r>=6;

Create New User

首先备份( <!--[endif]-->backup scott),在命令行下输入以下命令,按提示操作

exp

然后创建用户 <!--[endif]-->create user,在sqlplus下切换到管理员用户,输入

create user USER_NAME(such as:lue) identified by password(lue) default tablespace users quota(配额) 10M on users即是给用户分配10M的空间

其次是分配新建用户的权限,命令:

grant create session(登陆权限),creat table,create view to lue

最后导入数据 <!--[endif]-->import the data,在命令行下输入以下命令,按提示操作;

imp

一道SQL面试题

有3张表S,C,SC

S(sno,sname) 代表(学号,姓名)

C(cno,cname,cteacher)代表(课程号,课程名,教室)

SC(sno,cno,scgrade)代表(学号,课程号,成绩)

问题:

<!--[if !supportLists]-->1,  <!--[endif]-->找出没有选过“liming”老师的所有学生的姓名

<!--[if !supportLists]-->2,  <!--[endif]-->列出2门以上(含2门)不及格学生姓名及平均成绩

<!--[if !supportLists]-->3,  <!--[endif]-->学过1号课程又学过2号课程所有学生的姓名

答案:

//Answer 1:
select sname
from S join SC on(s.sno = sc.sno) join C (c.cno = sc.cno)
where C.cteacher <> ‘liming’;
//answer 2:
select sname
where sno in (select sno,count(*)
from SC
where scgrade < 60
group by sno
having count(*) >1);
//answer 3:
//方法1:
select sname
from S join (select sno
from SC
where C.cno = 1 and C.cno = 2) t
      on (S.sno = t.sno);
//方法2:
select  sname
from S
where sno in(select sno
     from SC
     where cno = 1 and cno in (select distinct sno
        from SC
        where cno = 2)
           );


 


本文出自:亿恩科技【www.enkj.com】

服务器租用/服务器托管中国五强!虚拟主机域名注册顶级提供商!15年品质保障!--亿恩科技[ENKJ.COM]

  • 您可能在找
  • 亿恩北京公司:
  • 经营性ICP/ISP证:京B2-20150015
  • 亿恩郑州公司:
  • 经营性ICP/ISP/IDC证:豫B1.B2-20060070
  • 亿恩南昌公司:
  • 经营性ICP/ISP证:赣B2-20080012
  • 服务器/云主机 24小时售后服务电话:0371-60135900
  • 虚拟主机/智能建站 24小时售后服务电话:0371-60135900
  • 专注服务器托管17年
    扫扫关注-微信公众号
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 亿恩科技 版权所有  地址:郑州市高新区翠竹街1号总部企业基地亿恩大厦  法律顾问:河南亚太人律师事务所郝建锋、杜慧月律师   京公网安备41019702002023号
      0
     
     
     
     

    0371-60135900
    7*24小时客服服务热线