📄 que_015.htm
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>Ocp test </title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<p align="left" color="black" style="font-size:16pt;">
<b>QUESTION 015
</b></p><hr color="#99CCFF">
<p>Examine the data in the EMPLOYEES and DEPARTMENTS tables:
EMPLOYEES </p><table border="1" bordercolor="gray" width="655">
<span style="font-size:18pt;">
<tr>
<td align="center" bgcolor="#99CCFF" width="114">
<p><b>EMPLOYEE_ID</b></p>
</td>
<td align="center" bgcolor="#99CCFF" width="104">
<p><b>EMP_NAME</b></p></b>
</td>
<td align="center" bgcolor="#99CCFF" width="98">
<p><b>DEPT_ID</b></p></b>
</td>
<td align="center" bgcolor="#99CCFF" width="98">
<p><b>MGR_ID</b></p></b>
</td>
<td align="center" bgcolor="#99CCFF" width="91">
<p><b>JOB_ID</b></p></b>
</td>
<td align="center" bgcolor="#99CCFF" width="110">
<p><b>SALARY</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114" height="21">
<p><b>101</b></p></b>
</td>
<td align="center" bgcolor="white" width="104" height="21">
<p><b>Smith</b></p></b>
</td>
<td align="center" bgcolor="white" width="98" height="21">
<p><b>20</b></p></b>
</td>
<td align="center" bgcolor="white" width="98" height="21">
<p><b>120</b></p></b>
</td>
<td align="center" bgcolor="white" width="91" height="21">
<p><b>SA_REP</b></p></b>
</td>
<td align="center" bgcolor="white" width="110" height="21">
<p><b>4000</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114" height="24">
<p><b>102</b></p></b>
</td>
<td align="center" bgcolor="white" width="104" height="24">
<p><b>Martin</b></p></b>
</td>
<td align="center" bgcolor="white" width="98" height="24">
<p><b>10</b></p></b>
</td>
<td align="center" bgcolor="white" width="98" height="24">
<p><b>105</b></p></b>
</td>
<td align="center" bgcolor="white" width="91" height="24">
<p><b>CLERK</b></p></b>
</td>
<td align="center" bgcolor="white" width="110" height="24">
<p><b>2500</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>103</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Chris</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>20</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>120</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>IT_ADMIN</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>4200</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>104</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>John</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>30</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>108</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>HR_CLERK</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>2500</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>105</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Diana</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>30</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>108</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>IT_ADMIN</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>5000</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>106</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Smith</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>40</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>110</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>AD_ASST</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>3000</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>108</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Jennifer</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>30</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>110</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>HR_DIR</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>6500</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>110</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Bob</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>40</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>EX_DIR</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>8000</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="114">
<p><b>120</b></p></b>
</td>
<td align="center" bgcolor="white" width="104">
<p><b>Ravi</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>20</b></p></b>
</td>
<td align="center" bgcolor="white" width="98">
<p><b>110</b></p></b>
</td>
<td align="center" bgcolor="white" width="91">
<p><b>SA*DIR</b></p></b>
</td>
<td align="center" bgcolor="white" width="110">
<p><b>6500</b></p></b>
</td>
</tr>
</span>
</table>
<p>DEPARTMENTS </p><table border="1" bordercolor="gray" width="398">
<span style="font-size:18pt;">
<tr>
<td align="center" bgcolor="#99CCFF" width="124">
<p><b>DEPARTMENT_ID</b></p></b>
</td>
<td align="center" bgcolor="#99CCFF" width="144">
<p><b>DEPARTMENT_NAME</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="124">
<p><b>10</b></p></b>
</td>
<td align="center" bgcolor="white" width="144">
<p><b>Admin</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="124">
<p><b>20</b></p></b>
</td>
<td align="center" bgcolor="white" width="144">
<p><b>Education</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="124">
<p><b>30</b></p></b>
</td>
<td align="center" bgcolor="white" width="144">
<p><b>IT</b></p></b>
</td>
</tr>
<tr>
<td align="center" bgcolor="white" width="124">
<p><b>40</b></p></b>
</td>
<td align="center" bgcolor="white" width="144">
<p><b>HumanResources</b></p></b>
</td>
</tr>
</span>
</table>
<p>Also examine the SQL statements that create the EMPLOYEES and DEPARTMENTS
tables: </p><table border="1" bordercolor="gray" width="658">
<tr>
<td align="left" bgcolor="white" width="648">
<p><b>CREATE TABLE departments <br> (department_id NUMBER PRIMARY KEY,<br>
department_name VARCHAR2(30));</b></p>
</td>
</tr>
<tr>
<td align="left" bgcolor="white" height="181" width="648">
<p><b>CREATE TABLE employees <br> (EMPLOYEE_ID NUMBER PRIMARY KEY, <br>
EMP_NAME VARCHAR2(20),<br> DEPT_ID NUMBER REFERENCES departments(department_id),<br>
MGR_ID NUMBER REFERENCES employees(employee id), <br>
JOB_ID VARCHAR2(15),<br> SALARY NUMBER); </b></p>
</td>
</tr>
</table>
<p>On the EMPLOYEES table, EMPLOYEE_ID is the primary key.
MGR_ID is the ID of managers and refers to the EMPLOYEE_ID.
DEPT_ID is foreign key to DEPARTMENT_ID column of the DEPARTMENTS table.
On the DEPARTMENTS table, DEPARTMENT_ID is the primary key.
Examine this DELETE statement: </p><p>DELETE
FROM departments
WHERE department_id = 40;
What happens when you execute the DELETE statement? </p><table border="1" bordercolor="gray" width="665">
<form name="youAnsForm">
<span style="font-size:18pt;">
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="A"> A.</b></p>
</td>
<td align="left" width="566">
<p> Only the row with department ID 40 is deleted in the DEPARTMENTS table.
</p>
</td>
</tr>
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="B"> B.</b></p>
</td>
<td align="left" width="566">
<p> The statement fails because there are child records in the EMPLOYEES table with department ID 40.
</p>
</td>
</tr>
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="C"> C.</b></p>
</td>
<td align="left" width="566">
<p> The row with department ID 40 is deleted in the
DEPARTMENTS table. Also the
rows with employee IDs 110 and 106 are deleted from the EMPLOYEES table.
</p>
</td>
</tr>
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="D"> D.</b></p>
</td>
<td align="left" width="566">
<p> The row with department ID 40 is deleted in the DEPARTMENTS table. Also the
rows with employee IDs 106 and 110 and the employees working under employee 110 are deleted from the EMPLOYEES table.
</p>
</td>
</tr>
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="E"> E.</b></p>
</td>
<td align="left" width="566">
<p> The row with department ID 40 is deleted in the DEPARTMENTS table. Also all the rows in the EMPLOYEES table are deleted.
</p>
</td>
</tr>
<tr>
<td align="center" width="89">
<p><b><input type="radio" name="AN" value="F"> F.</b></p>
</td>
<td align="left" width="566">
<p> The statement fails because there are no columns specifies in the DELETE clause of the DELETE statement.</p>
</td>
</tr>
</span>
</form>
</table>
<br></body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -