使用HQL查询所有部门信息,以下正确的是()。A、from DeptB、select*from cn.jbit.demo.entity.DeptC、select Dept from cn.jbit.demo.entity.Dept dD、select d from Dept d

题目

使用HQL查询所有部门信息,以下正确的是()。

  • A、from Dept
  • B、select*from cn.jbit.demo.entity.Dept
  • C、select Dept from cn.jbit.demo.entity.Dept d
  • D、select d from Dept d

相似考题
更多“使用HQL查询所有部门信息,以下正确的是()。A、from DeptB、select*from cn.jbit.demo.entity.DeptC、select Dept from cn.jbit.demo.entity.Dept dD、select d from Dept d”相关问题
  • 第1题:

    根据SQL标准,查询表student(sno,sname,sex,dept)中所有学生的选修课程数,其中选修记录在表SC(sno,cno,grade)中,两表中sno为关联字段。下面哪条语句合适?()

    A select sno,count(cno) from SC

    B select sno,count(cno) from student

    C select a.sno,count(cno) from student a left outer join SC

    D select a.sno,count(cno) from SC left outer join student a


    参考答案C

  • 第2题:

    在学生表STUD中查询所有姓张的学生的信息,使用的SQL语句是______。

    A.SELECT * FROM STUD WHERE 姓名LIKE“张%”

    B.SELECT * FROM STUD WHERE 姓名IN(“张%”)

    C.SELECT * FROM STUD WHERE 姓名LIKE“张$”

    D.SELECT * FROM STUD WHERE 姓名IN(“张$)”


    正确答案:A
    解析:在WHERE子句中可以使用查询条件谓词LIKE实现字符匹配。谓词LIKE的一般形式为“列名 LIKE字符串常数”,其中的列名的数据类型必须是字符型,在字符串常数中可以使用一些特殊字符来匹配字符。字符%(百分号)表示可以和任意长的字符串匹配。所以,选项A的语句正确。

  • 第3题:

    查询全体主管的姓名(m name)、出生年份(birth)和所在部门(dept),要求用小写字母表示所有部门名,数据表名为manager实现该功能的语句为________。

    A.select"m_name",出生年份:,birth,islower(dept)from manager

    B.select m_name,"出生年份:",birth,islower(dept)from manager

    C.select m_name,"出生年份:",birth,dept from manager

    D.select m_name,"出生年份:",birth,upper(dept)from manager


    正确答案:B
    解析:查询全体主管的姓名(m_name)、出生年份(birth)和所在部门(dept),要求用小写字母表示所有部门名。数据表为manager实现该功能的语句为:
      select m_name,"出生年份:",birth, islower(dept)
      from manager;

  • 第4题:

    对于学生信息表:student(sno,sname,sex,age,dept),要查询所有刘姓学生的信息,正确的语句是

    A.SELECT * FROM student WHERE sname LIKE'刘 * '

    B.SELECT * FROM student WHERE sname LIKE'刘 $'

    C.SELECT * FROM student WHERE sname LIKE'刘%'

    D.SELECT * FROM student WHERE sname LIKE'刘&'


    正确答案:C
    解析:%符号可以表示可以和任意长的字符串匹配。掌握SQL语言中其它特殊符号的含义和用法。

  • 第5题:

    找出emp表中的dept表没有的dept_no 使用Exists方式实现 即改写select * from emp a where a.dept_no not in (select b.dept_no from dept b)


    正确答案:SELECT *   FROM EMP A  WHERE NOT EXISTS  
     (SELECT 1 FROM DEPT B WHERE A.DEPT_NO = B. DEPT_NO) 

  • 第6题:

    关于HQL的聚合函数使用,说法正确的是()。

    • A、select count(*) from Dept d用于统计部门个数
    • B、select sum(e.salary) from Emp e用于汇总员工工资总额
    • C、select max(e.hiredate) from Emp e用于找到最新入职的员工的入职时间
    • D、select min(e.hiredate) from Emp e用于找到最早入职的员工的入职时间

    正确答案:A,B,C,D

  • 第7题:

    查询student表中的所有非空email信息,以下语句正确的是()。

    • A、Select email from student where email !=null
    • B、Select email from student where email not is null
    • C、Select email from student where email <> null
    • D、Select email from student where email is not null

    正确答案:D

  • 第8题:

    语句SELECT * FROM dept WHERE NOT EXISTS (SELECT * FROM emp WHERE deptno=dept.deptno)执行后的结果为()

    • A、只显示存在于EMP表中的部门全部信息
    • B、只显示不存在于EMP表中的部门全部信息
    • C、未返回任何数据
    • D、显示DEPT表中的全部信息

    正确答案:B

  • 第9题:

    Examine the description of the EMPLOYEES table: EMP_ID NUMBER(4) NOT NULL LAST_NAME VARCHAR2(30) NOT NULL FIRST_NAME VARCHAR2(30) DEPT_ID NUMBER(2) Which statement produces the number of different departments that have employees with last name Smith?()

    • A、SELECT COUNT(*) FROM employees WHERE last_name='Smith';
    • B、SELECT COUNT(dept_id) FROM employees WHERE last_name='Smith';
    • C、SELECT DISTINCT(COUNT(dept_id)) FROM employees WHERE last_name='Smith';
    • D、SELECT COUNT(DISTINCT dept_id) FROM employees WHERE last_name='Smith';
    • E、SELECT UNIQUE(dept_id) FROM employees WHERE last_name='Smith';

    正确答案:D

  • 第10题:

    Examine the description of the EMPLOYEES table: EMP_ID NUMBER(4) NOT NULL LAST_NAME VARCHAR2(30) NOT NULL FIRST_NAME VARCHAR2(30) DEPT_ID NUMBER(2) JOB_CAT VARCHARD2(30) SALARY NUMBER(8,2) Which statement shows the maximum salary paid in each job category of each department?()

    • A、SELECT dept_id, job_cat, MAX(salary) FROM employees WHERE salary > MAX (salary);
    • B、SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept_id,job_cat;
    • C、SELECT dept_id, job_cat, MAX(salary) FROM employees;
    • D、SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept_id;
    • E、SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept _ id job _ cat salary;

    正确答案:B

  • 第11题:

    Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()

    • A、SELECT * FROM emp_dept_vu;
    • B、SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department _ id;
    • C、SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department _ id, job_id;
    • D、SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM (salary) > 20000
    • E、None of the statements produce an error; all are valid.

    正确答案:E

  • 第12题:

    多选题
    在Hibernate的HQL查询中,有数据库表(dept)对应的对象名称为Dept,下列HQL写法正确的有()
    A

    String hql = from com.hr.g3.persist.dept as model;

    B

    String hql = from com.hr.g3.persist.Dept ;

    C

    String hql = from Dept as model;

    D

    String hql = from dept ;


    正确答案: C,D
    解析: 暂无解析

  • 第13题:

    Examine the description of the EMPLOYEES table:EMP_ID NUMBER(4) NOT NULLLAST_NAME VARCHAR2(30) NOT NULLFIRST_NAME VARCHAR2(30)DEPT_ID NUMBER(2)JOB_CAT VARCHARD2(30)SALARY NUMBER(8,2)Which statement shows the maximum salary paid in each job category of each department? ()

    A. SELECT dept_id, job_cat, MAX(salary) FROM employees WHERE salary > MAX (salary);

    B. SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept_id,job_cat;

    C. SELECT dept_id, job_cat, MAX(salary) FROM employees;

    D. SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept_id;

    E. SELECT dept_id, job_cat, MAX(salary) FROM employees GROUP BY dept _ id job _ cat salary;


    参考答案:B

  • 第14题:

    下图是使用查询设计器完成的查询,与该查询等价的SQL语句是 ______。

    A.select学号,数学from sc where 数学>(select avg(数学)from sC)

    B.select学号where数学>(select avg(数学)from sC)

    C.select数学avg(数学)from sc

    D.select数学>(select avg(数学)from sC)


    正确答案:A
    解析:由题目中的图片可以得出:查询条件的是“数学成绩大于数学平均分”,需要显示的字段是“学号”和“数学”,SQL语句中也应包含这些数据。

  • 第15题:

    在问题1定义的视图D_S上,下面哪个查询或更新是允许执行的,为什么?

    (1)Update D_S set D-3 where D=4;

    (2)Delete from D_Swhere C>4;

    (3)Select D,Averages from D_S

    where C>(Select C from D_S where D=:dept);

    (4)Select D,C From D_S

    where Totals>10000;

    (5)Select*from D_S;


    正确答案:此问考查的是对视图定义的掌握。 (1)和(2)都不能更新因为使用分组合聚集函数定义的视图是不可更新的。(3)不一定视子查询的返回值而定(4)和(5)允许查询。
    此问考查的是对视图定义的掌握。 (1)和(2)都不能更新,因为使用分组合聚集函数定义的视图是不可更新的。(3)不一定,视子查询的返回值而定,(4)和(5)允许查询。 解析:此问考查的是视图更新必须遵循的原则。因此,需要将SQL语句与定义该视图的 SQL语句结合起来考虑。由于SQL视图更新必须遵循以下规则:
    ▲从多个基本表通过连接操作导出的视图不允许更新。
    ▲对使用了分组、集函数操作的视图则不允许进行更新操作。
    ▲如果视图是从单个基本表通过投影、选取操作导出的则允许进行更新操作,且语法同基本表。
    (1)由于D_S视图中包含分组操作,也即将D_S视图合并到Update D_S set D=3 where D=4,结果为:Update 职工 set 部门号=3 where 部门号=4 GROUP BY 部门号,在 where 中包括 GROUP 分组操作,因此不能执行。
    (2)同理,将D_S视图合并到Delete from D_S where C>4中,结果为:Delete from职工where COUNT(职工号)>4 GROUP BY部门号,因此不能执行。
    (3)对于Select D,Averages from D_S where C>(Select C from D_S where D=:dept),要根据视图的返回值的情况。因此不一定能执行。
    (4)对于语句Select D,C From D_S where Totals>10000可以执行。
    (5)对于语句Select*from D_S显然是能执行的。

  • 第16题:

    Which of the following statements eliminates all but one of each set of duplicate rows in the DEPT column in the STAFF table?()

    A.SELECT UNIQUE dept FROM staff

    B.SELECT DISTINCT dept FROM staff

    C.SELECT (dept) UNIQUE FROM staff

    D.SELECT (dept) DISTINCT FROM staff


    参考答案:B

  • 第17题:

    在Hibernate的HQL查询中,有数据库表(dept)对应的对象名称为Dept,下列HQL写法正确的有()

    • A、String hql = "from com.hr.g3.persist.dept as model";
    • B、String hql = "from com.hr.g3.persist.Dept ";
    • C、String hql = "from Dept as model";
    • D、String hql = "from dept ";

    正确答案:B,C

  • 第18题:

    数据库表account对应实体类为Account类,以下HQL语句错误的有()。

    • A、select * from Account
    • B、From Account
    • C、From Account as model
    • D、Select * from account

    正确答案:D

  • 第19题:

    Which of the following statements eliminates all but one of each set of duplicate rows in the DEPT column in the STAFF table?()

    • A、SELECT UNIQUE dept FROM staff
    • B、SELECT DISTINCT dept FROM staff
    • C、SELECT (dept) UNIQUE FROM staff
    • D、SELECT (dept) DISTINCT FROM staff

    正确答案:B

  • 第20题:

    查询student表中的所有非空email信息,以下语句正确的是()

    • A、Select email from student where email!=null
    • B、Select email from student where emailnotisnull
    • C、Select email from student where email<>null
    • D、Select email from student where emailisnotnull

    正确答案:D

  • 第21题:

    当需要查询日志文件所有组及其成员的名称和文件位置,可以使用()方式。

    • A、SELECT * FROM V$LOGFILE
    • B、SELECT * FROM V$LOG
    • C、SELECT * FROM V$LOGHISTORY
    • D、SELECT * FROM V$DBA

    正确答案:A

  • 第22题:

    Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()

    • A、SELECT * FROM emp_dept_vu;
    • B、SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department _ id;
    • C、SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department _ id, job_id;
    • D、SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM (salary) > 20000
    • E、None of the statements produce an error; all are valid.

    正确答案:E

  • 第23题:

    多选题
    使用HQL查询所有部门信息,以下正确的是()。
    A

    from Dept

    B

    select*from cn.jbit.demo.entity.Dept

    C

    select Dept from cn.jbit.demo.entity.Dept d

    D

    select d from Dept d


    正确答案: C,B
    解析: 暂无解析