SQL - Milestone Assesment1 - MCQ - Final - 30
SQL - Milestone Assesment1 - MCQ - Final - 30
Please read the question carefully and choose ON DELETE CASCADE ON DELETE SET NULL
the most appropriate option. To automatically
delete rows in a child table when a parent record
is deleted use:
Please read the question carefully and choose SELECT CustomerName, SELECT CustomerName,
the most appropriate option. Which of the COUNT(CustomerName) FROM COUNT(CustomerName)
following SQL statements is correct? Orders ORDER BY CustomerName FROM Orders GROUP BY
CustomerName
Please read the question carefully and choose UPDATE employees SET first_name UPDATE employees SET
the most appropriate option. Examine the = 'John' AND last_name ='Smith' first_name = 'John' SET
structure of the EMPLOYEES table: WHERE employee_id = 180; last_name ='Smith'
EMPLOYEE_ID NUMBER Primary Key WHERE employee_id =
FIRST_NAME VARCHAR2(25) 180;
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
Which UPDATE statement is valid?
You created a view called EMP_DEPT_VU that ALTER VIEW emp_dept_vu (ADD MODIFY VIEW
contains three columns from the manager_id NUMBER); emp_dept_vu (ADD
EMPLOYEES and DEPARTMENTS tables: manager_id NUMBER);
CUSTOMERS
CUST_ID CUST_NAME CITY
10 Smith Los Angeles
15 Bob San Francisco
20 Martin Chicago
25 Mary New York
30 Rina Chicago
35 Smith New York
40 Linda New York
The STUDENT_GRADES table has these columns: SELECT MAX(gpa) FROM SELECT (gpa) FROM
student_grades WHERE gpa IS NOT student_grades GROUP BY
STUDENT_ID NUMBER(12) NULL; semester_end WHERE gpa
SEMESTER_END DATE IS NOT
GPA NUMBER(4,3) NULL;
Statement 2:
SELECT last_name, salary, hire_date FROM
EMPLOYEES ORDER BY salary limit 2;
Statement 3:
SELECT last_name, salary, hire_date FROM
EMPLOYEES ORDER BY 2 DESC limit 2;
Statement 4:
SELECT last_name, salary, hire_date FROM
EMPLOYEES ORDER BY 2 limit 2;
Examine the description of the MARKS table: The statement executes The statement returns an
successfully and returns the error
STD_ID INT student ID and sum of all marks
STUDENT_NAME VARCHAR(30) for each student who obtained
SUBJ1 INT more than the average mark in
SUBJ2 INT each subject.
Please read the question carefully and choose LIKE ...... (that's six dots) LIKE ??????
the most appropriate option. In a LIKE clause,
you can ask for any 6 letter value by writing?
Please read the question carefully and choose create a new table in the database modify an existing table in
the most appropriate option. The SQL DROP a database
TABLE clause is used to...
Which statement selects the employee details SELECT * FROM employee SELECT * FROM employee
whose first name starts with 'S' followed by any WHERE first_name LIKE '%S_s%'; WHERE first_name LIKE
one character. Third character should be 's' 'S_s%';
followed by any characters.
Select the statement that shows the employees' SELECT first_name, department_id, SELECT first_name,
name, department id , job id and the salary of job_id, salary department_id, job_id,
the employees working in department 80 and FROM employees salary
their job ascending and the salary in descending WHERE department_id = 80 FROM employees
order ORDER BY job_id ASC, salary DESC; WHERE department_id =
80
ORDER BY salary ASC,
job_id DESC ;
Which statement generates a report from SELECT employee_id || is || SELECT employee_id is
employee tables for all employees as follows last_name last_name
|| and works as ||job_id and works as job_id
101 is King and works as AD_PRES with salary of || with salary of Rs ||salary with salary of Rs salary
Rs 24000 FROM employees; FROM employees;
Select all employees who are working in SELECT * FROM employees SELECT * FROM
department 30 as job_id 'PU_CLERK' WHERE department_id IN 30 employees
AND job_id ('PU_CLERK'); WHERE department_id IN
30
OR job_id = 'PU_CLERK';
Calculate the total salary of employees on depar SELECT department_id, SELECT department_id,
SUM(salary) SUM(salary)
FROM employees FROM employees
GROUP BY department_id; HAVING department_id;
Select only the groups which are having total SELECT department_id, SELECT department_id,
salary greater than 13,000/- SUM(salary) SUM(salary)
FROM employees FROM employees
GROUP BY department_id GROUP BY department_id
ORDER BY department_id; HAVING SUM(salary) >
13000;
SELECT department_id FROM employees All distinct rows selected by the all rows selected by either
INTERSECT first query,
SELECT department_id FROM departments; query but not the second query including all duplicates
Add a new column - mark NUMBER(4) - to ALTER TABLE student ALTER TABLE student
student table MODIFY mark NUMBER(4); ADD (mark NUMBER(4));
What is INLINE VIEW A subquery in the WHERE clause of A subquery in the GROUP
a SELECT statement BY clause of a SELECT
statement
UPDATE employees SET UPDATE employees SET first_name = UPDATE employees SET first_name
first_name = 'John', SET 'John', last_name ='Smith' WHERE = 'John', last_name ='Smith'
last_name ='Smith' WHERE employee_id = 180; WHERE employee_id = 180;
employee_id = 180;
CREATE OR REPLACE VIEW You must remove the existing view CREATE OR REPLACE VIEW
emp_dept_vu AS first, and then run the CREATE VIEW emp_dept_vu AS
SELECT employee_id, command SELECT employee_id,
employee_name, with a new column list to modify a employee_name,
department_name, view department_name, manager_id
manager_id FROM employees e, departments
FROM employees e, d WHERE e.department_id =
departments d WHERE d.department_id;
e.department_id =
d.department_id;
SELECT ord_id, cust_id, SELECT ord_id, cust_id, ord_total SELECT ord_id, cust_id, ord_total
ord_total FROM orders FROM orders FROM orders
Where ord_date IN (SELECT WHERE cust_id IN (SELECT cust_id Where ord_date IN (SELECT
ord_date FROM orders, FROM customers ord_date
customers WHERE cust name = ‘Martin’); FROM orders WHERE cust_id =
Where cust_name = (SELECT cust_id
‘Martin’); FROM customers WHERE
cust_name = ‘Martin’));
SELECT city_address, SELECT city_address, SELECT city_address, COUNT(*)
COUNT(customer_id) FROM COUNT(customer_id) FROM customers FROM customers WHERE
customers WHERE GROUP BY city_address city_address IN ('Los
city_address IN IN ('Los Angeles', 'San Francisco'); Angeles', 'San Francisco') GROUP
('Los Angeles', 'San BY city_address;
Francisco') GROUP BY
city_address, customer_id;
LIKE .{6} Answer 5: LIKE ^. LIKE ______ (that's six underscore LIKE ______ (that's six underscore
{6}$ characters) characters)
delete a table from the Removes All rows from the table delete a table from the database
database
10 50 50
all distinct rows selected by only distinct rows that appear in either all distinct rows selected by
both queries result both queries
A subquery in the ORDER BY A subquery in the FROM clause of a A subquery in the FROM clause of
clause of a SELECT statement SELECT statement a SELECT statement
D
B
C
B
B
C
C
B
A
A
C
D
A