1Z0-007 考试题

发布于 2024-09-26 16:23:47 字数 339 浏览 1 评论 0原文

问题: 哪四个子句可以使用子查询? (选择四项。)

A. INSERT 语句的 INTO 子句中

B. SELECT 语句的 FROM 子句中

C. SELECT 语句的 GROUP BY 子句中

D. SELECT 语句的 WHERE 子句

中 E. UPDATE 语句的 SET 子句

F. INSERT 语句的 VALUES 子句中

答案:B、D、E、F

但我认为正确的答案如下:A、B、D、 E 但不是 F。不是这样吗???

Question:
In which four clauses can a subquery be used? (Choose four.)

A. in the INTO clause of an INSERT statement

B. in the FROM clause of a SELECT statement

C. in the GROUP BY clause of a SELECT statement

D. in the WHERE clause of a SELECT statement

E. in the SET clause of an UPDATE statement

F. in the VALUES clause of an INSERT statement

Answer: B, D, E, F

But I think right answers are the following: A, B, D, E BUT NOT F. Is not it so???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

听不够的曲调 2024-10-03 16:23:47

不,B、D、E、F 听起来是正确的。

为什么你认为 A 应该有效? INTO 正在指定目标行集,该目标行集不能是子查询。在 F 中,您可以使用返回标量值的子查询。

No, B, D, E, F sounds correct.

Why do you thik A should be valid? The INTO is designating a target rowset, which cannot be a subquery. And in F you can use subqueries which return a scalar value just fine.

澜川若宁 2024-10-03 16:23:47

首先,我们必须承认子查询返回一组值元组(行):{(value_1_A, value_1_B, ...), (value_2_A, value_2_B, ...), ...}

A - INTO 子句需要一个表名,而不是一组值,因此您不能使用子查询。请注意,这与 B 不同,因为您可以查询匿名表(子查询返回的一组行),但是将值插入匿名表中是没有意义的,因为匿名表不会被使用。

F - INSERT 语句的 VALUES 子句期望的正是我所说的子查询返回的一组值。

正确答案是BDEF

以下是有关子查询的更多信息: http://www.techonthenet.com/oracle/subqueries.php< /a>

First of all we must acknowledge that a subquery returns a set of value tuples (rows): {(value_1_A, value_1_B, ...), (value_2_A, value_2_B, ...), ...}

A - The INTO clause expects a table name, not a set of values so you may not use a subquery. Note that this is not similar to B because you are allowed to query an anonymous table (a set of rows returned by a subquery), but it makes no sense to insert values into an anonymous table that will not be used.

F - The VALUES clause of the INSERT statement expects exactly what I said a subquery returns, a set of values.

The right answer will be B, D, E and F.

Here's some more info on subqueries: http://www.techonthenet.com/oracle/subqueries.php

溺ぐ爱和你が 2024-10-03 16:23:47

抢夺! ...我发现了一些非常重要的东西,这证明了我的断言...

其他DML语句中的子查询

子查询可以在DML语句中使用,例如INSERTUPDATE 删除

合并。以下是 DML

语句中子查询的一些示例。

将所有员工的工资更新为

相应部门的最高工资(相关子查询):

UPDATE employees e1

SET  salary = (SELECT MAX(salary)

     FROM  employees e2

     WHERE e1.department_id = e2.department_id);

删除工资低于部门平均工资的员工记录

(使用相关子查询):

DELETE FROM employees e

WHERE salary < (SELECT AVG(salary) FROM employees

      WHERE  department_id = e.department_id);

使用以下命令向表中插入记录 :子查询:

INSERT INTO employee_archive

SELECT * FROM employees;

在 INSERT 语句的 VALUES 子句中指定子查询:

INSERT INTO departments

       (department_id, department_name)

VALUES ((SELECT MAX(department_id)

         +10 FROM departments), 'EDP');

您还可以在 INSERT、UPDATE 和 DELETE 语句中使用子查询来代替表名。下面是一个示例:

DELETE FROM

(SELECT * FROM departments

 WHERE department_id < 20)

WHERE department_id = 10;




INSERT INTO (SELECT department_id, department_name

FROM departments

WHERE department_id < 20)

VALUES (35, 'MARKETING');

已创建 1 行。

Loot at! ...I found something very important,which proves my assertion...

Subqueries in Other DML Statements

Subqueries can be used in DML statements such as INSERT, UPDATE, DELETE,

and MERGE. Following are some examples of subqueries in DML

statements.

To update the salary of all employees to the maximum salary in the

corresponding department (correlated subquery):

UPDATE employees e1

SET  salary = (SELECT MAX(salary)

     FROM  employees e2

     WHERE e1.department_id = e2.department_id);

To delete the records of employees whose salary is below the average

salary in the department (using a correlated subquery):

DELETE FROM employees e

WHERE salary < (SELECT AVG(salary) FROM employees

      WHERE  department_id = e.department_id);

To insert records to a table using a subquery:

INSERT INTO employee_archive

SELECT * FROM employees;

To specify a subquery in the VALUES clause of the INSERT statement:

INSERT INTO departments

       (department_id, department_name)

VALUES ((SELECT MAX(department_id)

         +10 FROM departments), 'EDP');

You can also have a subquery in the INSERT, UPDATE, and DELETE statements in place of the table name. Here is an example:

DELETE FROM

(SELECT * FROM departments

 WHERE department_id < 20)

WHERE department_id = 10;




INSERT INTO (SELECT department_id, department_name

FROM departments

WHERE department_id < 20)

VALUES (35, 'MARKETING');

1 row created.

枕头说它不想醒 2024-10-03 16:23:47

子查询可以用在 INSERT 语句的 INTO 子句中。所以A也是正确答案。

以下查询有效:

insert into (select name from emp) 
values ((select 'sunil' from dual));

Subquery can be used in the INTO clause of an INSERT statement. So A also correct answer.

The below query works:

insert into (select name from emp) 
values ((select 'sunil' from dual));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文