Back to Dashboard

Database Management

Complete Subject Question Bank

01 Rdbms Concepts#1

Tom has designed a payroll software for XYZ technology.The sofware will store the salary details into the database and later he can retreive the same for future references. Tom falls under which category of user.

A
Application Programmer
B
Database Administrator
C
End User
D
System Analyst

Tom writes application code that stores and retrieves data — he is an Application Programmer.

01 Rdbms Concepts#2

In SQL is a case sensitive language and the data stored inside the table are case in-sensitive. Say true or false?

A
TRUE
B
FALSE

SQL keywords are case-insensitive; data values are case-sensitive by default in most RDBMS.

01 Rdbms Concepts#3

Which of the following is not a valid relational database?

A
XML Database
B
Oracle
C
MySQL
D
PostgreSQL

XML databases are hierarchical/document stores, not relational databases.

01 Rdbms Concepts#4

Database is a shared collection of logically unrelated data, designed to meet the needs of an organization. State True or False.

A
TRUE
B
FALSE

A database is a collection of logically RELATED data — the statement is false.

01 Rdbms Concepts#5

Which of the following represents the degree of the relation?

A
Number of attributes (columns)
B
Number of tuples (rows)
C
Number of tables
D
Number of keys

The degree of a relation is its number of attributes.

03 Data Definition Language#6

A table consists of ______ primary keys.

A
1
B
2
C
Multiple
D
0

Each table has exactly one primary key (which may be composite).

03 Data Definition Language#7

We need to ensure that the amount withdrawn should be less then the credit card limit amount, to ensure this integrity what type constraint will be used?

A
Table level CHECK constraint
B
NOT NULL constraint
C
UNIQUE constraint
D
PRIMARY KEY constraint

A CHECK constraint enforces domain integrity rules like withdrawal limits.

03 Data Definition Language#8

Which of the following options is not correct?

A
alter table emp drop column_name;
B
alter table emp drop column salary;
C
alter table emp add column salary number;
D
alter table emp modify salary varchar(20);

The correct syntax is ALTER TABLE emp DROP COLUMN salary; — missing the COLUMN keyword.

03 Data Definition Language#9

An emp table contains fields employ name, desig and salary. How do you drop column salary?

A
alter table emp drop column salary;
B
drop column salary from emp;
C
alter emp drop salary;
D
delete column salary from emp;

The correct DDL is: ALTER TABLE emp DROP COLUMN salary;

03 Data Definition Language#10

Which of the following is not modification of the database

A
XML Database
B
Oracle
C
MySQL
D
PostgreSQL

XML databases are hierarchical/document stores, not relational databases.

03 Data Definition Language#11

In a relational database a referential integrity constraint can be done using

A
Foreign Key
B
Primary Key
C
CHECK constraint
D
UNIQUE constraint

Foreign Keys enforce referential integrity between tables.

03 Data Definition Language#12

___________ removes data from the table, but structure remains the same.

A
TRUNCATE
B
DROP
C
DELETE
D
ALTER

TRUNCATE removes all rows but preserves the table structure; it is a DDL command.

03 Data Definition Language#13

A relational database consists of a collection of

A
Tables (relations)
B
Objects
C
Files
D
Documents

A relational database organises data into tables (relations).

03 Data Definition Language#14

Column header is referred as

A
Attribute
B
Tuple
C
Domain
D
Relation

A column header in a relational table is called an attribute.

04 Data Manipulation Language#15

Consider the below table structure: Column Name DataType Constraint Empname Varchar(20) Not Null EmpId int(10) PK Phoneno bigint(10) Not Null insert into employee(empid,empname)values('123','John'); When we issue the above insert command and if the statement fails, what would be the reason.

A
Value for phoneno is missing.
B
empid value should be given without single quotes.
C
The statement will execute successfully.
D
The empname value should be given without single quotes.

phoneno has a NOT NULL constraint so it must be provided. empid is numeric so no quotes needed — that part is actually correct; the real issue is only the missing phoneno value.

04 Data Manipulation Language#16

Examine the structure of the STUDENT table: Column Name DataType Constraint Stud_id int(3) PK Name Varchar(20) Not Null Address Varchar(30) DOB Date Which statement inserts a new row into the STUDENT table?

A
INSERT INTO student VALUES(101, 'Smith', '15-JAN-1990', 'New York');
B
INSERT INTO student(stud_id, name) VALUES(101, 'Smith');
C
INSERT INTO student VALUES(101);
D
INSERT INTO student(name) VALUES('Smith');

Providing all column values in the correct order satisfies the table constraints.

04 Data Manipulation Language#17

State True or False. COMMIT ends the current transaction by making all pending data changes permanent.

A
TRUE
B
FALSE

COMMIT permanently saves all changes made in the current transaction.

04 Data Manipulation Language#18

Merge is not supported by MySQL. The other possible way of doing the work of merge statement, is by using ON DUPLICATE KEY UPDATE in the insert statement. State TRUE or FALSE.

A
True
B
False

MySQL uses INSERT ... ON DUPLICATE KEY UPDATE as an alternative to MERGE.

04 Data Manipulation Language#19

Which of the below is a reference option for deleting rows from a table?

A
ON DELETE CASCADE
B
ON DELETE RESTRICT
C
ON DELETE SET NULL
D
ON DELETE NO ACTION

ON DELETE CASCADE automatically deletes child rows when the parent row is deleted.

04 Data Manipulation Language#20

To remove a relation from SQL database, we use ___________ command.

A
DROP
B
DELETE
C
TRUNCATE
D
ALTER

DROP TABLE removes the entire table structure and data from the database.

04 Data Manipulation Language#21

What is the Default format for Date datatype?

A
YYYY-MM-DD (ISO standard) / DD-MON-RR (Oracle)
B
MM/DD/YYYY
C
DD/MM/YYYY
D
MMDDYYYY

ISO standard is YYYY-MM-DD; Oracle default is DD-MON-RR.

04 Data Manipulation Language#22

Numeric datatype is used to store_______

A
Whole numbers and decimals
B
Text only
C
Dates only
D
Boolean values

NUMERIC/NUMBER stores integer and decimal numeric values.

05 Sql Select Statement#23

Which statement about SQL is true?

A
Null values are displayed last in ascending sequences.
B
Null values are displayed first in ascending sequences.
C
Date values are displayed in descending order by default.
D
Column aliases cannot be used in ORDER BY.

In most RDBMS (Oracle, MySQL, PostgreSQL), NULL values appear last in ASC order (NULLS LAST by default).

05 Sql Select Statement#24

Select the suitable option for retrieving all the employees who have a manager?

A
SELECT empname, manager_id FROM employee WHERE manager_id IS NOT NULL;
B
SELECT * FROM employee WHERE manager_id = NULL;
C
SELECT * FROM employee WHERE manager_id != 0;
D
SELECT * FROM employee;

Use IS NOT NULL to filter rows where manager_id has a value.

05 Sql Select Statement#25

Select the suitable option for retrieving all the employees whose last name is "kumar"?

A
SELECT * FROM employee WHERE last_name = 'kumar';
B
SELECT * FROM employee WHERE last_name LIKE 'kumar%';
C
SELECT * FROM employee WHERE last_name LIKE '%kumar';
D
SELECT * FROM employee WHERE last_name != 'kumar';

Exact match uses = operator.

05 Sql Select Statement#26

How to retrieve department_id column without any duplication from employee relation?

A
SELECT DISTINCT department_id FROM employee;
B
SELECT department_id FROM employee;
C
SELECT UNIQUE department_id FROM employee;
D
SELECT TOP 1 department_id FROM employee;

DISTINCT removes duplicates from the result set.

05 Sql Select Statement#27

Which statement is true when a DROP TABLE command is executed on a table?

A
Any pending transactions are rolled back; the structure and data cannot be recovered.
B
The DROP TABLE command can be executed on a table with pending transactions.
C
Only a DBA can execute the DROP TABLE command.
D
The data can be rolled back after DROP TABLE.

DROP TABLE is DDL — it auto-commits, rolls back pending transactions, and is irreversible without a backup.

05 Sql Select Statement#28

Which statements are true regarding constraints? Select one or more: A constraint is enforced only for the INSERT operation on a table. A foreign key cannot contain NULL values. A columns with the UNIQUE constraint can contain NULL values. A constraint can be disabled even if the constraint column contains data.

A
A foreign key cannot contain NULL values. A columns with the UNIQUE constraint can contain NULL values. A constraint can be disabled even if the constraint column contains dat
B
, A columns with the UNIQUE constraint can contain NULL values.

UNIQUE columns can contain NULL; constraints can be disabled while data exists.

05 Sql Select Statement#29

You need to remove all the data from the employee table while leaving the table definition intact. You want to be able to undo this operation. How would you accomplish this task?

A
DELETE FROM employee;
B
TRUNCATE TABLE employee;
C
DROP TABLE employee;
D
ALTER TABLE employee;

DELETE is DML and can be rolled back; TRUNCATE cannot be rolled back.

05 Sql Select Statement#30

The SQL statements executed in a user session as follows: create table product(pid int(10),pname varchar(10)); Insert into product values(1,'pendrive'); Insert into product values(2,'harddisk'); savepoint a; update product set pid=20 where pid=1; savepoint b; delete from product where pid=2; commit; delete from product where pid=10; Which statements describe the consequence of issuing the ROLLBACK TO SAVE POINT a command in the session?

A
The table contains: p1-pen, p2-pencil (rows before the savepoint are kept).
B
The table is empty (all rows are rolled back).
C
The table contains: p1-pen, p2-pencil, p3-eraser (all rows retained).
D
An error is raised because savepoint names must be unique.

ROLLBACK TO SAVEPOINT sp1 undoes changes after the savepoint, so only p3-eraser is removed. p1 and p2 remain.

06 Function-Scalar & Aggregate#31

All columns in the SELECT list that are not in group functions must be in the GROUP-BY clause. State True or False.

A
TRUE
B
FALSE

SQL requires non-aggregated SELECT columns to appear in GROUP BY.

06 Function-Scalar & Aggregate#32

Group functions can be used in the where clause. State True or False.

A
TRUE
B
FALSE

Group functions cannot be used in WHERE; use HAVING instead.

06 Function-Scalar & Aggregate#33

Single row functions can be nested to any level. State true or False.

A
TRUE
B
FALSE

Single-row functions can be nested to any depth in SQL.

06 Function-Scalar & Aggregate#34

What will be the output for the below query: select ceil(5.3) from dual;

A
6
B
5
C
5.3
D
NULL

CEIL rounds up: CEIL(5.3) = 6.

06 Function-Scalar & Aggregate#35

We need to create a report to display the order id, ship date and order total of your ORDER table. If the order has not been shipped, your report must display 'Not Shipped'. If the total is not available, your report must display 'Not Available'. In the ORDER table, the SHIPDATE column has a datatype of DATE. The TOTAL column has a datatype of INT. Which statement do you use to create this report?

A
SELECT ordid, IFNULL(shipdate, 'Not Shipped') SHIPDATE, IFNULL(total,'Not Available') TOTAL FROM order;
B
SELECT ordid, IFNULL(shipdate, 'Not Shipped') as SHIPDATE, Total FROM order;
C
SELECT ordid, TO_CHAR(shipdate, 'Not Shipped'), TO_CHAR(total,'Not Available') FROM order;
D
SELECT ordid, shipdate 'Not Shipped', total 'Not Available' FROM order;

IFNULL(expr, replacement) returns the replacement when expr is NULL. Both columns need IFNULL applied.

06 Function-Scalar & Aggregate#36

To generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed. Which SQL statement would produce the required result?

A
SELECT NVL(TO_CHAR(cust_credit_limit*.15),'Not Available') "NEW CREDIT" FROM customers;
B
SELECT IFNULL(cust_credit_limit * 0.15,'Not Available') "NEW CREDIT" FROM customers;
C
SELECT NULLIF(cust_credit_limit*.15,'Not Available') "NEW CREDIT" FROM customers;
D
All the options

NVL with TO_CHAR conversion is correct Oracle syntax: NVL(TO_CHAR(expr), 'Not Available').

06 Function-Scalar & Aggregate#37

To display the names of employees that are not assigned to a department. Evaluate this SQL statement: SELECT last_name, first_name FROM employee WHERE dept_id = NULL; Which change should you make to achieve the desired result?

A
Change the = operator to IS NULL in the WHERE clause.
B
Add NOT in front of NULL.
C
Change = to <> NULL.
D
No change needed; the query is correct.

NULL comparisons require IS NULL / IS NOT NULL. Using = NULL always evaluates to UNKNOWN.

06 Function-Scalar & Aggregate#38

Which statement is true regarding the default behavior of the ORDER BY clause?

A
Ascending order
B
Descending order
C
Random order
D
As stored in the table

The default ORDER BY sort order is ascending (ASC).

06 Function-Scalar & Aggregate#39

ABC company wants to give each employee a $100 salary increment. You need to evaluate the results from the EMP table prior to the actual modification. If you do not want to store the results in the database, which statement is valid?

A
You need to give the arithmetic expression in the SELECT clause, not the UPDATE clause.
B
You need to give the arithmetic expression that involves the salary increment in the UPDATE clause.
C
The query is correct as written.
D
You need to use a subquery to add $100 to the salary.

To preview salary increments, use arithmetic in the SELECT clause: SELECT salary + 100 FROM employee;

06 Function-Scalar & Aggregate#40

Select the suitable option for fetching the output of the following query. select substr("Oracle World",1,6) from dual;

A
Oracle
B
World
C
Oracle W
D
racle W

SUBSTR('Oracle World', 1, 6) starts at position 1 and takes 6 characters = 'Oracle'.

07 Joins & Subquery#41

Which operator is NOT appropriate in the join condition of a non-equi join SELECT statement?

A
=
B
BETWEEN
C
>
D
<

Non-equi joins use non-equality operators; = is for equi-joins.

07 Joins & Subquery#42

In which cases would you use an outer join?

A
Only when the tables have a primary key/foreign key relationship. The tables being joined have only matched dat
B
The tables being joined have only unmatched dat

Outer joins return matched and unmatched rows from one or both tables.

07 Joins & Subquery#43

To display the names of employees who earns more than the average salary of all employees. SELECT last_name, first_name FROMemployee WHEREsalary > AVG(salary); Which change should you make to achieve the desired results?

A
Move the function to the SELECT clause and add a GROUP BY clause and a HAVING claus
B
Use a subquery in the WHERE clause to compare the average salary valu
C
Move the function to the SELECT clause and add a GROUP BY claus

A correlated subquery in WHERE is needed to compare each salary to the average.

07 Joins & Subquery#44

To create a report displaying employee last names, department names, and locations. Which query should you use to create an equi- join?

A
department_id =
B
department_id; SELECT
C
last_name
D
department_name
E
location_id FROM employees e, departments d WHERE manager_id =manager_id; SELECT
F
last_name
G
department_name
H
location_id FROM employees e, departments d WHERE
I
department_id =
J
department_id;
K
last_name
L
depa5rtme2nt_na2me, 4
M
loca8tion_id FROM employees e, departments d WHERE
N
department_id =
O
department_id;

Refer to Database Management — 07 Joins & Subquery study materials.

07 Joins & Subquery#45

Which statement would display the highest credit limit available in each income level in each city in the Customers table?

A
SELECT city, income_level, MAX(cust_credit_limit) FROM customers GROUP BY city, income_level;
B
SELECT MAX(cust_credit_limit) FROM customers;
C
SELECT city, MAX(cust_credit_limit) FROM customers GROUP BY city;
D
SELECT income_level, MAX(cust_credit_limit) FROM customers GROUP BY income_level;

GROUP BY both city and income_level with MAX gives the required result.

07 Joins & Subquery#46

Which SQL statement produces an error?

A
SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM(salary) > ;
B
SELECT * FROM emp_dept_vu;
C
SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department_id, job_id;
D
None of these produce an error.

The HAVING clause is incomplete — no value after '>', causing a syntax error.

07 Joins & Subquery#47

The COMMISSION column shows the monthly commission earned by the employee. Emp_Id Dept_Id Commission 1 10 500 2 20 1000 3 10 4 10 600 5 30 800 6 30 200 7 10 8 20 300 Which tasks would require sub queries or joins in order to be performed in a single step? Select one or more: Listing the employees who earn the same amount of commission as employee 3 Listing the employees whose annual commission is more than 6000 Listing the departments whose average commission is more that 600 Listing the employees who do not earn commission and who are working for department 20 in descending order of the employee ID Finding the total commission earned by the employees in department 10 Finding the number of employees who earn a commission that is higher than the average commission of the company

A
Listing the employees who earn the same amount of commission as employee 3
B
Listing the employees whose annual commission is more than 6000
C
Listing the departments whose average commission is more than 600
D
Finding the number of employees who earn a commission higher than the average

Tasks requiring subqueries: finding employees matching employee 3's commission (correlated subquery) and finding employees above average commission (scalar subquery).

07 Joins & Subquery#48

What statement would display the age of Customers with the alias name as AGE?

A
SELECT (SYSDATE - dob) / 365 AS AGE FROM customers;
B
SELECT age FROM customers;
C
SELECT AGE FROM customers;
D
SELECT dob AS AGE FROM customers;

Age is calculated from the date of birth using date arithmetic, aliased as AGE.

08 Dcl & Database Objects#49

Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema?

A
DROP VIEW emp_dept_vu;
B
DELETE VIEW emp_dept_vu;
C
REMOVE VIEW emp_dept_vu;
D
ALTER VIEW emp_dept_vu DROP;

DROP VIEW is the correct SQL syntax to remove a view.

08 Dcl & Database Objects#50

CREATE INDEX emp_dept_id_idx ON employee(dept_id); Which of the following statements are true with respect to the above index?

A
May reduce the amount of disk I/O for SELECT statements.
B
Stores an index in the EMPLOYEE table.
C
Increases the chance of full table scans.
D
Overrides the unique index.

An index on dept_id speeds up SELECT queries filtering by that column by reducing disk I/O.

08 Dcl & Database Objects#51

An owner can give specific privileges on the owner's objects to others. State True or False.

A
TRUE
B
FALSE

Object owners can GRANT specific privileges to other users.

08 Dcl & Database Objects#52

The owner has all the privileges on the object. State true or False.

A
TRUE
B
FALSE

An object owner automatically has all privileges on that object.

08 Dcl & Database Objects#53

Which SQL statement grants a privilege to all the database users?

A
GRANT SELECT ON employees TO PUBLIC;
B
GRANT SELECT ON employees TO ALL;
C
GRANT ALL ON employees;
D
GRANT SELECT ON employees TO USERS;

GRANT ... TO PUBLIC gives the privilege to all current and future users.

08 Dcl & Database Objects#54

Equijoin is called as ______.

A
Inner join / Simple join
B
Outer join
C
Self join
D
Cross join

An equijoin uses the = operator and is also called an inner/simple join.

08 Dcl & Database Objects#55

_____ is used to retrieve records that do not meet the join condition

A
Outer join
B
Inner join
C
Self join
D
Cross join

Outer joins return rows that do not satisfy the join condition (unmatched rows).

08 Dcl & Database Objects#56

Joining a table to itself is called as ______.

A
Self join
B
Cross join
C
Natural join
D
Equijoin

A self join joins a table to itself using aliases.

08 Dcl & Database Objects#57

The _______ join is based on all columns in the two tables that have the same data type.

A
Natural
B
Cross
C
Full Outer
D
Left Outer

NATURAL JOIN automatically joins on all columns with matching names and data types.

08 Dcl & Database Objects#58

The _______ join produces the cross product of two tables.

A
Cross join
B
Natural join
C
Outer join
D
Self join

A CROSS JOIN produces the Cartesian product of two tables.

1. Rdbms Concepts#59

Tom has designed a payroll software for XYZ technology.The sofware will store the salary details into the database and later he can retreive the same for future references. Tom falls under which category of user.

A
Application Programmer
B
Database Administrator
C
End User
D
System Analyst

Tom writes application code that stores and retrieves data — he is an Application Programmer.

1. Rdbms Concepts#60

Which of the following is not a valid relational database?

A
XML Database
B
Oracle
C
MySQL
D
PostgreSQL

XML databases are hierarchical/document stores, not relational databases.

1. Rdbms Concepts#61

SQL is a case sensitive language and the data stored inside the table are case in-sensitive. Say true or false?

A
TRUE
B
FALSE

SQL keywords are case-insensitive; data values are case-sensitive by default.

1. Rdbms Concepts#62

Which of the following represents the degree of the relation?

A
Number of attributes (columns)
B
Number of tuples (rows)
C
Number of tables
D
Number of keys

The degree of a relation is its number of attributes.

1. Rdbms Concepts#63

Database is a shared collection of logically unrelated data, designed to meet the needs of an organization. State True or False.

A
TRUE
B
FALSE

A database is a collection of logically RELATED data — the statement is false.

3. Data Definition Language#64

We need to ensure that the amount withdrawn should be less then the credit card limit amount, to ensure this integrity what type constraint will be used?

A
Table level CHECK constraint
B
NOT NULL constraint
C
UNIQUE constraint
D
PRIMARY KEY constraint

A CHECK constraint enforces domain integrity rules like withdrawal limits.

3. Data Definition Language#65

A table consists of ______ primary keys.

A
1
B
2
C
Multiple
D
0

Each table has exactly one primary key (which may be composite).

3. Data Definition Language#66

An emp table contains fields employ name, desig and salary. How do you drop column salary?

A
alter table emp drop column salary;
B
drop column salary from emp;
C
alter emp drop salary;
D
delete column salary from emp;

The correct DDL is: ALTER TABLE emp DROP COLUMN salary;

3. Data Definition Language#67

Which of the following options is not correct?

A
alter table emp drop column_name;
B
alter table emp drop column salary;
C
alter table emp add column salary number;
D
alter table emp modify salary varchar(20);

The correct syntax is ALTER TABLE emp DROP COLUMN salary; — missing the COLUMN keyword.

3. Data Definition Language#68

Which of the following is not modification of the database

A
Sorting
B
INSERT
C
UPDATE
D
DELETE

Sorting (ORDER BY) is a retrieval operation, not a data modification.

3. Data Definition Language#69

A relational database consists of a collection of

A
Tables (relations)
B
Objects
C
Files
D
Documents

A relational database organises data into tables (relations).

3. Data Definition Language#70

Column header is referred as

A
Attribute
B
Tuple
C
Domain
D
Relation

A column header in a relational table is called an attribute.

3. Data Definition Language#71

___________ removes data from the table, but structure remains the same.

A
TRUNCATE
B
DROP
C
DELETE
D
ALTER

TRUNCATE removes all rows but preserves the table structure; it is a DDL command.

3. Data Definition Language#72

In a relational database a referential integrity constraint can be done using

A
Foreign Key
B
Primary Key
C
CHECK constraint
D
UNIQUE constraint

Foreign Keys enforce referential integrity between tables.

4. Data Manipulation Language#73

Merge is not supported by MySQL. The other possible way of doing the work of merge statement, is by using ON DUPLICATE KEY UPDATE in the insert statement. State TRUE or FALSE.

A
True
B
False

MySQL uses INSERT ... ON DUPLICATE KEY UPDATE as an alternative to MERGE.

4. Data Manipulation Language#74

Consider the below table structure: Column Name DataType Constraint Empname Varchar(20) Not Null EmpId int(10) PK Phoneno bigint(10) Not Null insert into employee(empid,empname)values('123','John'); When we issue the above insert command and if the statement fails, what would be the reason.

A
Value for phoneno is missing.
B
empid value should be given without single quotes.
C
The statement will execute successfully.
D
The empname value should be given without single quotes.

phoneno has a NOT NULL constraint so it must be provided. The statement fails because phoneno is missing.

4. Data Manipulation Language#75

Examine the structure of the STUDENT table: Column Name DataType Constraint Stud_id int(3) PK Name Varchar(20) Not Null Address Varchar(30) DOB Date Which statement inserts a new row into the STUDENT table?

A
INSERT INTO student VALUES(101, 'Smith', '15-JAN-1990', 'New York');
B
INSERT INTO student(stud_id, name) VALUES(101, 'Smith');
C
INSERT INTO student VALUES(101);
D
INSERT INTO student(name) VALUES('Smith');

Providing all column values in the correct order satisfies the table constraints.

4. Data Manipulation Language#76

State True or False. COMMIT ends the current transaction by making all pending data changes permanent.

A
TRUE
B
FALSE

COMMIT permanently saves all changes made in the current transaction.

4. Data Manipulation Language#77

Numeric datatype is used to store_______

A
Whole numbers and decimals
B
Text only
C
Dates only
D
Boolean values

NUMERIC/NUMBER stores integer and decimal numeric values.

4. Data Manipulation Language#78

Which of the below is a reference option for deleting rows from a table?

A
ON DELETE CASCADE
B
ON DELETE RESTRICT
C
ON DELETE SET NULL
D
ON DELETE NO ACTION

ON DELETE CASCADE automatically deletes child rows when the parent row is deleted.

4. Data Manipulation Language#79

To remove a relation from SQL database, we use ___________ command.

A
DROP
B
DELETE
C
TRUNCATE
D
ALTER

DROP TABLE removes the entire table structure and data from the database.

4. Data Manipulation Language#80

What is the Default format for Date datatype?

A
YYYY-MM-DD (ISO standard) / DD-MON-RR (Oracle)
B
MM/DD/YYYY
C
DD/MM/YYYY
D
MMDDYYYY

ISO standard is YYYY-MM-DD; Oracle default is DD-MON-RR.

5. Sql Select Statement#81

How to retrieve department_id column without any duplication from employee relation?

A
SELECT DISTINCT department_id FROM employee;
B
SELECT department_id FROM employee;
C
SELECT UNIQUE department_id FROM employee;
D
SELECT TOP 1 department_id FROM employee;

DISTINCT removes duplicates from the result set.

5. Sql Select Statement#82

Select the suitable option for retrieving all the employees who have a manager?

A
SELECT empname, manager_id FROM employee WHERE manager_id IS NOT NULL;
B
SELECT * FROM employee WHERE manager_id = NULL;
C
SELECT * FROM employee WHERE manager_id != 0;
D
SELECT * FROM employee;

Use IS NOT NULL to filter rows where manager_id has a value.

5. Sql Select Statement#83

Select the suitable option for retrieving all the employees whose last name is "kumar"?

A
SELECT * FROM employee WHERE last_name = 'kumar';
B
SELECT * FROM employee WHERE last_name LIKE 'kumar%';
C
SELECT * FROM employee WHERE last_name LIKE '%kumar';
D
SELECT * FROM employee WHERE last_name != 'kumar';

Exact match uses = operator.

5. Sql Select Statement#84

Which statement about SQL is true?

A
Null values are displayed last in ascending sequences.
B
Null values are displayed first in ascending sequences.
C
Date values are displayed in descending order by default.
D
Column aliases cannot be used in ORDER BY.

In most RDBMS (Oracle, MySQL, PostgreSQL), NULL values appear last in ASC order (NULLS LAST by default).

5. Sql Select Statement#85

Which statement is true when a DROP TABLE command is executed on a table?

A
Any pending transactions on the table are rolled back. The table structure and its deleted data cannot be rolled back and restored once the DROP TABLE command is execute
B
The DROP TABLE command can be executed on a table on which there are pending transactions.

DROP TABLE is DDL — it auto-commits and cannot be rolled back.

5. Sql Select Statement#86

Which statements are true regarding constraints? Select one or more: Af i k t t i NULL l A foreign key cannot contain NULL values. A constraint is enforced only for the INSERT operation on a table. A columns with the UNIQUE constraint can contain NULL values. A constraint can be disabled even if the constraint column contains data.

A
A columns with the UNIQUE constraint can contain NULL values. A constraint can be disabled even if the constraint column contains dat
B
, A columns with the UNIQUE constraint can contain NULL values.

UNIQUE columns can contain NULL; constraints can be disabled while data exists.

5. Sql Select Statement#87

The SQL statements executed in a user session as follows: create table product(pid int(10),pname varchar(10)); Insert into product values(1,'pendrive'); Insert into product values(2,'harddisk'); savepoint a; update product set pid=20 where pid=1; savepoint b; delete from product where pid=2; commit; delete from product where pid=10; Which statements describe the consequence of issuing the ROLLBACK TO SAVE POINT a command in the session?

A
The table contains: p1-pen, p2-pencil (rows before the savepoint are kept).
B
The table is empty (all rows are rolled back).
C
The table contains: p1-pen, p2-pencil, p3-eraser (all rows retained).
D
An error is raised because savepoint names must be unique.

ROLLBACK TO SAVEPOINT sp1 undoes changes after the savepoint, so only p3-eraser is removed. p1 and p2 remain.

5. Sql Select Statement#88

You need to remove all the data from the employee table while leaving the table definition intact. You want to be able to undo this operation. How would you accomplish this task?

A
DELETE FROM employee;
B
TRUNCATE TABLE employee;
C
DROP TABLE employee;
D
ALTER TABLE employee;

DELETE is DML and can be rolled back; TRUNCATE cannot.

6. Function-Scalar & Aggregate#89

What will be the output for the below query: select ceil(5.3) from dual;

A
6
B
5
C
5.3
D
NULL

CEIL rounds up: CEIL(5.3) = 6.

6. Function-Scalar & Aggregate#90

Single row functions can be nested to any level. State true or False.

A
TRUE
B
FALSE

Single-row functions can be nested to any depth in SQL.

6. Function-Scalar & Aggregate#91

All columns in the SELECT list that are not in group functions must be in the GROUP-BY clause. State True or False.

A
TRUE
B
FALSE

SQL requires non-aggregated SELECT columns to appear in GROUP BY.

6. Function-Scalar & Aggregate#92

Group functions can be used in the where clause. State True or False.

A
TRUE
B
FALSE

Group functions cannot be used in WHERE; use HAVING instead.

6. Function-Scalar & Aggregate#93

We need to create a report to display the order id, ship date and order total of your ORDER table. If the order has not been shipped, your report must display 'Not Shipped'. If the total is not available, your report must display 'Not Available'. In the ORDER table, the SHIPDATE column has a datatype of DATE. The TOTAL column has a datatype of INT. Which statement do you use to create this report?

A
SELECT ordid, IFNULL(shipdate, 'Not Shipped') SHIPDATE, IFNULL(total,'Not Available') TOTAL FROM order;
B
SELECT ordid, IFNULL(shipdate, 'Not Shipped') as SHIPDATE, Total FROM order;
C
SELECT ordid, TO_CHAR(shipdate, 'Not Shipped'), TO_CHAR(total,'Not Available') FROM order;
D
SELECT ordid, shipdate 'Not Shipped', total 'Not Available' FROM order;

IFNULL(expr, replacement) returns the replacement when expr is NULL. Both columns need IFNULL applied.

6. Function-Scalar & Aggregate#94

Select the suitable option for fetching the output of the following query. select substr("Oracle World",1,6) from dual;

A
Oracle
B
World
C
Oracle W
D
racle W

SUBSTR('Oracle World', 1, 6) starts at position 1 and takes 6 characters = 'Oracle'.

6. Function-Scalar & Aggregate#95

To display the names of employees that are not assigned to a department. Evaluate this SQL statement: SELECT last_name, first_name FROM employee WHERE dept_id = NULL; Which change should you make to achieve the desired result?

A
Change the = operator to IS NULL in the WHERE clause.
B
Add NOT in front of NULL.
C
Change = to <> NULL.
D
No change needed; the query is correct.

NULL comparisons require IS NULL / IS NOT NULL. Using = NULL always evaluates to UNKNOWN.

6. Function-Scalar & Aggregate#96

ABC company wants to give each employee a $100 salary increment. You need to evaluate the results from the EMP table prior to the actual modification. If you do not want to store the results in the database, which statement is valid?

A
You need to give the arithmetic expression in the SELECT clause, not the DISPLAY clause.
B
You need to give the arithmetic expression that involves the salary increment in the DISPLAY clause.
C
The query is correct as written.
D
You need to use a subquery to add $100 to the salary.

The correct clause to calculate salary + 100 for display is SELECT, not DISPLAY.

6. Function-Scalar & Aggregate#97

To generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed. Which SQL statement would produce the required result?

A
SELECT NVL(TO_CHAR(cust_credit_limit*.15),'Not Available') "NEW CREDIT" FROM customers;
B
SELECT IFNULL(cust_credit_limit * 0.15,'Not Available') "NEW CREDIT" FROM customers;
C
SELECT NULLIF(cust_credit_limit*.15,'Not Available') "NEW CREDIT" FROM customers;
D
All the options

NVL with TO_CHAR conversion is correct Oracle syntax: NVL(TO_CHAR(expr), 'Not Available').

6. Function-Scalar & Aggregate#98

Which statement is true regarding the default behavior of the ORDER BY clause?

A
Ascending order
B
Descending order
C
Random order
D
As stored in the table

The default ORDER BY sort order is ascending (ASC).

7. Joins & Subquery#99

To display the names of employees who earns more than the average salary of all employees. SELECT last_name, first_name FROMemployee WHEREsalary > AVG(salary); Which change should you make to achieve the desired results?

A
Move the function to the SELECT clause and add a GROUP BY claus
B
Use a subquery in the WHERE clause to compare the average salary valu
C
Change the function in the WHERE claus

A correlated subquery in WHERE is needed to compare each salary to the average.

7. Joins & Subquery#100

In which cases would you use an outer join? Selectone: Seec o e: The tables being joined have only unmatched data. Only when the tables have a primary key/foreign key relationship. The tables being joined have only matched data. The tables being joined have both matched and unmatched data. The tables being joined have NOT NULL columns.

A
Only when the tables have a primary key/foreign key relationship. The tables being joined have only matched dat
B
The tables being joined have both matched and unmatched dat
C
The tables being joined have NOT NULL columns.

Outer joins return matched and unmatched rows from one or both tables.

7. Joins & Subquery#101

Which operator is NOT appropriate in the join condition of a non-equi join SELECT statement?

A
=
B
BETWEEN
C
>
D
<

Non-equi joins use non-equality operators; = is for equi-joins.

7. Joins & Subquery#102

Which statement would display the highest credit limit available in each income level in each city in the Customers table?

A
SELECT city, income_level, MAX(cust_credit_limit) FROM customers GROUP BY city, income_level;
B
SELECT MAX(cust_credit_limit) FROM customers;
C
SELECT city, MAX(cust_credit_limit) FROM customers GROUP BY city;
D
SELECT income_level, MAX(cust_credit_limit) FROM customers GROUP BY income_level;

GROUP BY both city and income_level with MAX gives the required result.

7. Joins & Subquery#103

What statement would display the age of Customers with the alias name as AGE?

A
SELECT (SYSDATE - dob) / 365 AS AGE FROM customers;
B
SELECT age FROM customers;
C
SELECT AGE FROM customers;
D
SELECT dob AS AGE FROM customers;

Age is calculated from the date of birth using date arithmetic, aliased as AGE.

7. Joins & Subquery#104

Which SQL statement produces an error?

A
SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM(salary) > ;
B
SELECT * FROM emp_dept_vu;
C
SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department_id, job_id;
D
None of these

The HAVING clause is incomplete — missing the value after >.

7. Joins & Subquery#105

The COMMISSION column shows the monthly commission earned by the employee. Emp_Id Dept_Id Commission 1 10 500 2 20 1000 3 10 4 10 600 5 30 800 6 30 200 7 10 8 20 300 Which tasks would require sub queries or joins in order to be performed in a single step? Select one or more: Listing the employees who earn the same amount of commission as employee 3 Finding the total commission earned by the employees in department 10 Listing the departments whose average commission is more that 600 Listing the employees whose annual commission is more than 6000 Finding the number of employees who earn a commission that is higher than the average commission of the company Listing the employees who do not earn commission and who are working for department 20 in descending order of the employee ID

A
Listing the employees who earn the same amount of commission as employee 3
B
Listing the employees whose annual commission is more than 6000
C
Listing the departments whose average commission is more than 600
D
Finding the number of employees who earn a commission higher than the average

Tasks requiring subqueries: finding employees matching employee 3's commission (correlated subquery) and finding employees above average commission (scalar subquery).

7. Joins & Subquery#106

To create a report displaying employee last names, department names, and locations. Which query should you use to create an equi-join?

A
department_id =
B
department_id; SELECT
C
last_name
D
department_name
E
location_id FROM employees e, departments d WHERE manager_id =manager_id; SELECT
F
last_name
G
department_name
H
location_id FROM employees e, departments d WHERE
I
department_id =
J
department_id; SELECT last_name, department_name, location_id FROM employees , departments ;
K
last_name
L
department_name
M
location_id FROM employees e, departments d WHERE
N
department_id =
O
department_id;

Refer to Database Management — 7. Joins & Subquery study materials.

8. Dcl & Database Objects#107

An owner can give specific privileges on the owner's objects to others. State True or False.

A
TRUE
B
FALSE

Object owners can GRANT specific privileges to other users.

8. Dcl & Database Objects#108

Which SQL statement grants a privilege to all the database users?

A
GRANT SELECT ON employees TO PUBLIC;
B
GRANT SELECT ON employees TO ALL;
C
GRANT ALL ON employees;
D
GRANT SELECT ON employees TO USERS;

GRANT ... TO PUBLIC gives the privilege to all current and future users.

8. Dcl & Database Objects#109

CREATE INDEX emp_dept_id_idx ON employee(dept_id); Which of the following statements are true with respect to the above index?

A
May reduce the amount of disk I/O for INSERT statements. Increase the chance of full table scans. Override the unique index created when the FK relationship was define
B
May reduce the amount of disk I/O for SELECT statements.

An index on dept_id speeds up SELECT queries filtering by that column.

8. Dcl & Database Objects#110

Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema?

A
DROP VIEW emp_dept_vu;
B
DELETE VIEW emp_dept_vu;
C
REMOVE VIEW emp_dept_vu;
D
ALTER VIEW emp_dept_vu DROP;

DROP VIEW is the correct SQL syntax to remove a view.

8. Dcl & Database Objects#111

The owner has all the privileges on the object. State true or False.

A
TRUE
B
FALSE

An object owner automatically has all privileges on that object.

8. Dcl & Database Objects#112

Joining a table to itself is called as ______.

A
Self join
B
Cross join
C
Natural join
D
Equijoin

A self join joins a table to itself using aliases.

8. Dcl & Database Objects#113

Equijoin is called as ______.

A
Inner join / Simple join
B
Outer join
C
Self join
D
Cross join

An equijoin uses the = operator and is also called an inner/simple join.

8. Dcl & Database Objects#114

The _______ join is based on all columns in the two tables that have the same data type.

A
Natural
B
Cross
C
Full Outer
D
Left Outer

NATURAL JOIN automatically joins on all columns with matching names and data types.

8. Dcl & Database Objects#115

The _______ join produces the cross product of two tables.

A
Cross join
B
Natural join
C
Outer join
D
Self join

A CROSS JOIN produces the Cartesian product of two tables.

8. Dcl & Database Objects#116

_____ is used to retrieve records that do not meet the join condition

A
Outer join
B
Inner join
C
Self join
D
Cross join

Outer joins return rows that do not satisfy the join condition (unmatched rows).

Data Definition Language#117

Which command is used to change a table's behavior?

A
ALTER
B
MODIFY
C
UPDATE
D
CHANGE

ALTER TABLE is the DDL command used to change a table's structure/behavior.

Data Definition Language#118

We need to ensure that the amount withdrawn should be less then the credit card limit amount, to ensure this integrity what type constraint will be used?

A
Table level CHECK constraint
B
NOT NULL constraint
C
UNIQUE constraint
D
PRIMARY KEY constraint

A CHECK constraint enforces business rules such as keeping withdrawal below the credit limit.

Data Definition Language#119

An emp table contains fields employ name, desig and salary. How do you drop column salary?

A
ALTER TABLE emp DROP COLUMN salary;
B
DROP COLUMN salary FROM emp;
C
ALTER emp DROP salary;
D
DELETE COLUMN salary FROM emp;

The correct DDL syntax is: ALTER TABLE emp DROP COLUMN salary;

Data Definition Language#120

How would you add a foreign key constraint on the dept_no column in the EMP table, referring to the id column in the DEPT table?

A
Use the ALTER TABLE command with the ADD clause on the EMP table.
B
Use the ALTER TABLE command with the MODIFY clause on the EMP table.
C
Use the CREATE TABLE command with the FOREIGN KEY clause.
D
Use the DROP TABLE command and recreate the table.

ALTER TABLE EMP ADD CONSTRAINT fk_dept FOREIGN KEY (dept_no) REFERENCES dept(dept_no);

Data Definition Language#121

A table consists of ______ primary keys.

A
1
B
2
C
Multiple
D
0

Each table can have exactly one primary key (which may be composite).

Data Definition Language#122

__________ command is used to delete the records and _________ command is used to delete the db objects?

A
DELETE, TRUNCATE
B
TRUNCATE, DROP
C
DROP, DELETE
D
DELETE, DROP

DELETE removes records (DML); TRUNCATE removes all rows and resets table (DDL).

Data Definition Language#123

Which of the following options is not correct?

A
ALTER TABLE emp DROP column_name;
B
ALTER TABLE emp DROP COLUMN salary;
C
ALTER TABLE emp ADD COLUMN salary NUMBER;
D
ALTER TABLE emp MODIFY salary VARCHAR(20);

The correct syntax requires the COLUMN keyword: ALTER TABLE emp DROP COLUMN salary; — DROP column_name; is invalid.

Data Definition Language#124

Which of the following is not modification of the database?

A
Sorting
B
INSERT
C
UPDATE
D
DELETE

ORDER BY (sorting) is a retrieval operation, not a data modification.

Data Definition Language#125

Which of the following data models supports many-to-many relationships?

A
Relational model and Network model
B
Hierarchical model only
C
Relational model only
D
Object model only

Both relational and network data models support many-to-many relationships.

Data Definition Language#126

Which of the following is not a part of RDBMS?

A
Polymorphism
B
Tables
C
Primary Keys
D
Foreign Keys

Polymorphism is an OOP concept, not part of RDBMS.

Data Definition Language#127

Which of these are standard and best practises for SQL?

A
Each table must have a primary key.
B
Tables should not have foreign keys.
C
NULL values should never be used.
D
All columns must have unique values.

Best practice mandates every table has a primary key to uniquely identify rows.

Data Manipulation Language#128

Which are auto-commit statements?

A
DROP and TRUNCATE
B
INSERT and UPDATE
C
DELETE and UPDATE
D
SELECT and INSERT

DROP and TRUNCATE are DDL statements that auto-commit; they cannot be rolled back.

Data Manipulation Language#129

Which of the update statement produces the following error in the employee table? ORA-02291: integrity constraint (SYS_C23) violated - parent key not found.

A
UPDATE Employee SET Deptid=3 WHERE Empid = 101;
B
UPDATE Employee SET Deptid=3;
C
UPDATE Employee SET Empid = 101;
D
UPDATE Employee SET Deptid=3, Empid=101;

Setting a foreign key value to a non-existent department ID causes an integrity constraint violation.

Data Manipulation Language#130

Which of the following is not a DML statement?

A
DROP and ALTER
B
INSERT
C
UPDATE
D
DELETE

DROP and ALTER are DDL statements, not DML. DML includes INSERT, UPDATE, DELETE, SELECT.

Data Manipulation Language#131

Which SQL statement needs both insert and update privilege on the target table and select privilege on the source table?

A
MERGE
B
INSERT
C
UPDATE
D
DELETE

MERGE (upsert) requires both INSERT and UPDATE privileges on the target table.

Data Manipulation Language#132

On delete restrict is used to restrict the deletion of child records. State True or False.

A
TRUE
B
FALSE

Refer to Database Management — Data Manipulation Language study materials.

Data Manipulation Language#133

Delete statement supports up to two conditions only. State True or False

A
TRUE
B
FALSE

Refer to Database Management — Data Manipulation Language study materials.

Data Manipulation Language#134

Which statement inserts a new row into the STUDENT table?

A
INSERT INTO student VALUES(101, 'Smith', '15-JAN-1990', 'New York');
B
INSERT INTO student(stud_id, address, name, dob) VALUES(101);
C
INSERT INTO student VALUES(101);
D
INSERT INTO student(name) VALUES('Smith');

Providing all required column values in the correct positional order is valid.

Data Manipulation Language#135

insert into employee(empid,empname)values(123,'John'); When we issue the above insert command and if the statement fails, what would be the reason.

A
Value for phoneno is missing.
B
The statement will execute successfully.
C
empid value should be given without single quotes.
D
empname value should be given without single quotes.

phoneno has a NOT NULL constraint so it must be provided; omitting it causes an error.

Data Manipulation Language#136

DELETE FROM dept WHERE dept_id = 901; The above delete statement throws an integrity constraint error because a child record was found. What could we do to make the statement execute?

A
Delete the child records first.
B
Use DROP TABLE instead.
C
Use TRUNCATE instead.
D
Add a NOT NULL constraint.

An integrity constraint error occurs when a parent record has child records. Delete children first or use ON DELETE CASCADE.

Data Manipulation Language#137

Which query is used to delete employee records whose age is greater than 55?

A
DELETE FROM employee WHERE age > 55;
B
DROP FROM employee WHERE age > 55;
C
TRUNCATE employee WHERE age > 55;
D
REMOVE FROM employee WHERE age > 55;

DELETE with a WHERE clause filters which rows are removed.

Data Manipulation Language#138

By using _____ datatype we can store numeric and character values as an input .

A
VARCHAR2, VARCHAR, CHAR
B
NUMBER, INTEGER
C
DATE, TIMESTAMP
D
BOOLEAN, BIT

VARCHAR2, VARCHAR, and CHAR are character datatypes that can store both numeric and character values as text.

Data Manipulation Language#139

To permanently remove all the data from the STUDENT table, and you need the table structure in the future. Which single command performs this?

A
TRUNCATE TABLE student;
B
DELETE FROM student;
C
DROP TABLE student;
D
ALTER TABLE student;

TRUNCATE permanently removes all rows but keeps the table structure intact; it cannot be rolled back.

Data Manipulation Language#140

Which statement would you use to add a primary key constraint to the patient table using the id_number column, immediately enabling the constraint?

A
ALTER TABLE patient ADD CONSTRAINT pat_id_pk PRIMARY KEY(id_number);
B
ALTER TABLE patient ADD PRIMARY KEY;
C
CREATE CONSTRAINT pat_id_pk PRIMARY KEY ON patient(id_number);
D
ALTER patient ADD CONSTRAINT pat_id_pk PRIMARY KEY(id_number);

The correct syntax is ALTER TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY(column);

Data Manipulation Language#141

Composite key is used in one to one relationship. State true or false.

A
TRUE
B
FALSE

Refer to Database Management — Data Manipulation Language study materials.

Data Manipulation Language#142

Which CREATE TABLE statement is valid?

A
CREATE TABLE ord_details (ord_no NUMBER(2), item_no NUMBER(3), ord_date DATE DEFAULT SYSDATE NOT NULL, CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));
B
CREATE TABLE ord_details (ord_no NUMBER(2), item_no NUMBER(3), ord_date DATE DEFAULT SYSDATE, CONSTRAINT ord_pk);
C
CREATE TABLE ord_details ord_no NUMBER(2), item_no NUMBER(3);
D
CREATE ord_details TABLE (ord_no NUMBER(2));

The statement correctly defines columns, a DEFAULT, NOT NULL, and a composite PRIMARY KEY constraint.

Data Manipulation Language#143

Cascade constraints are used only in drop statements. State True or False.

A
TRUE
B
FALSE

Refer to Database Management — Data Manipulation Language study materials.

Function - Scalar & Aggregate#144

select substr("Oracle World",1,6) from dual;

A
Oracle
B
World
C
Oracle W
D
racle W

SUBSTR('Oracle World', 1, 6) starts at position 1 and returns 6 characters = 'Oracle'.

Function - Scalar & Aggregate#145

ABC company wants to give each employee a $100 salary increment. You need to evaluate the results from the EMP table prior to the actual modification. If you do not want to store the results in the database, which statement is valid?

A
You need to give the arithmetic expression in the SELECT clause, not the DISPLAY clause.
B
You need to give the arithmetic expression that involves the salary increment in the DISPLAY clause.
C
The query is correct as written.
D
You need to use a subquery to add $100 to the salary.

The correct clause to calculate salary + 100 for display is SELECT, not DISPLAY.

Function - Scalar & Aggregate#146

To display the names of all promos done after January 1, 2001 starting with the latest promo. Which query would give the required result? (Choose all that apply.)

A
SELECT promo_name, promo_begin_date "START DATE" FROM promotions WHERE promo_begin_date > '01-JAN-01' ORDER BY "START DATE" DESC;
B
SELECT promo_name, promo_begin_date FROM promotions ORDER BY promo_begin_date;
C
SELECT promo_name FROM promotions WHERE promo_begin_date > '01-JAN-01';
D
SELECT * FROM promotions ORDER BY promo_begin_date DESC;

The query filters by date, uses a column alias 'START DATE', and orders descending.

Function - Scalar & Aggregate#147

Which statement is true regarding the default behavior of the ORDER BY clause?

A
In a character sort, the values are case-sensitive.
B
Numeric values are sorted in descending order by default.
C
NULL values are always sorted first.
D
ORDER BY always requires DESC keyword.

Character sort in ORDER BY is case-sensitive by default in most RDBMS.

Function - Scalar & Aggregate#148

To calculate the number of days from 1st Jan 2007 till date: Dates are stored in the default format of dd-mm-rr. Which SQL statements would give the required output?

A
SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL;
B
SELECT SYSDATE - '01-JAN-2007' FROM DUAL;
C
SELECT DATEDIFF(SYSDATE, '01-JAN-2007') FROM DUAL;
D
SELECT DAYS_BETWEEN(SYSDATE, TO_DATE('01-JAN-2007')) FROM DUAL;

In Oracle, subtracting two dates gives the number of days. TO_DATE converts the string to a date.

Function - Scalar & Aggregate#149

To generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed. Which SQL statement would produce the required result?

A
SELECT NVL(TO_CHAR(cust_credit_limit*.15), 'Not Available') "NEW CREDIT" FROM customers;
B
SELECT IFNULL(cust_credit_limit * 0.15, 'Not Available') "NEW CREDIT" FROM customers;
C
SELECT NULLIF(cust_credit_limit*.15, 'Not Available') "NEW CREDIT" FROM customers;
D
SELECT cust_credit_limit * 0.15 "NEW CREDIT" FROM customers;

NVL(TO_CHAR(expr), 'Not Available') handles NULL: converts the number to string first so both arguments are the same type.

Function - Scalar & Aggregate#150

The CUSTOMERS table has these columns: CUSTOMER_ID NUMBER(4) NOT NULL; CUSTOMER_NAME VARCHAR2(100) NOT NULL; CUSTOMER_ADDRESS VARCHAR2(150); CUSTOMER_PHONE VARCHAR2(20); You need to produce output that states "Dear Customer customer_name, ". The customer_name data values come from the CUSTOMER_NAME column in the CUSTOMERS table. Which statement produces this output?

A
SELECT 'Dear Customer ' || customer_name || ',' FROM customers;
B
SELECT CONCAT('Dear Customer', customer_name) FROM customers;
C
SELECT 'Dear Customer' + customer_name FROM customers;
D
SELECT customer_name FROM customers;

The || operator concatenates strings in Oracle SQL.

Function - Scalar & Aggregate#151

Generate a list of all customer last names with their credit limits from the CUSTOMERS table. Customers who do not have a credit limit should appear last in the list. kindly note that customers who do not have credit card will have NULL against credit limit.Which query would achieve the required result?

A
SELECT cust_last_name, cust_credit_limit FROM customers ORDER BY cust_credit_limit;
B
SELECT * FROM customers;
C
SELECT cust_last_name FROM customers ORDER BY cust_credit_limit DESC;
D
SELECT cust_last_name, cust_credit_limit FROM customers;

ORDER BY cust_credit_limit sorts ascending by default, generating the required list.

Function - Scalar & Aggregate#152

To display the names of employees that are not assigned to a department. Evaluate this SQL statement: SELECT last_name, first_name FROM employee WHERE dept_id = NULL; .Which change should you make to achieve the desired result?

A
Change the operator in the WHERE condition to IS NULL.
B
Add NOT in front of NULL.
C
Change = to <> NULL.
D
No change needed; the query is correct.

NULL comparisons require IS NULL / IS NOT NULL. Using = NULL always evaluates to UNKNOWN.

Function - Scalar & Aggregate#153

To update the CUST_CREDIT_LIMIT column to NULL for all the customers, where CUST_INCOME_LEVEL has NULL in the CUSTOMERS table. Which SQL statement will accomplish the task?

A
UPDATE customers SET cust_credit_limit = NULL WHERE cust_income_level IS NULL;
B
UPDATE customers SET cust_credit_limit = 0 WHERE cust_income_level = NULL;
C
DELETE FROM customers WHERE cust_income_level IS NULL;
D
ALTER TABLE customers SET cust_credit_limit = NULL;

IS NULL is required for NULL comparison; SET cust_credit_limit = NULL explicitly sets the column to NULL.

Rdbms Concepts#154

Tom has designed a payroll software for XYZ technology.The software will store the salary details into the database and later he can retrieve the same for future references. Tom falls under which category of user.

A
Application Programmer
B
Database Administrator
C
End User
D
System Analyst

Tom writes application code that stores and retrieves data — he is an Application Programmer.

Select Statement#155

Which statement is used to manipulate data without affecting the data in the table?

A
SELECT
B
INSERT
C
UPDATE
D
DELETE

SELECT is a read-only DML statement that retrieves data without modifying it.

Select Statement#156

Which operator is equivalent to the ‘or’ operator?

A
IN
B
AND
C
BETWEEN
D
LIKE

The IN operator is equivalent to multiple OR conditions: col IN (a, b) = col = a OR col = b.

Select Statement#157

How to retrieve department_id column without any duplication from employee relation?

A
SELECT DISTINCT department_id FROM employee;
B
SELECT department_id FROM employee;
C
SELECT UNIQUE department_id FROM employee;
D
SELECT TOP 1 department_id FROM employee;

DISTINCT removes duplicate values from the result set.

Select Statement#158

Select the suitable option for retrieving all the employees whose name ends with "kumar"?

A
SELECT * FROM employee WHERE empname LIKE '%kumar';
B
SELECT * FROM employee WHERE empname LIKE 'kumar%';
C
SELECT * FROM employee WHERE empname = 'kumar';
D
SELECT * FROM employee WHERE empname LIKE '%kumar%';

The % wildcard at the start matches any prefix; '%kumar' matches names ending with 'kumar'.

Select Statement#159

Select the suitable option for retrieving all the employees whose salary range is between 40000 and 100000?

A
SELECT name, salary FROM employee WHERE salary >= 40000 AND salary <= 100000;
B
SELECT * FROM employee WHERE salary BETWEEN 40001 AND 99999;
C
SELECT * FROM employee WHERE salary > 40000 AND salary < 100000;
D
SELECT name FROM employee WHERE salary = 40000 OR salary = 100000;

Using >= and <= correctly captures the inclusive range 40000–100000.

Select Statement#160

Which statement about SQL is true?

A
Null values are displayed last in ascending sequences.
B
Null values are displayed first in ascending sequences.
C
Date values are displayed in descending order by default.
D
Column aliases cannot be used in ORDER BY.

NULL values appear last in ascending order (NULLS LAST is the default in most RDBMS).

Select Statement#161

Select the suitable option for retrieving all the employees who have a manager?

A
SELECT empname, manager_id FROM employee WHERE manager_id IS NOT NULL;
B
SELECT * FROM employee WHERE manager_id = NULL;
C
SELECT * FROM employee WHERE manager_id != 0;
D
SELECT * FROM employee;

IS NOT NULL correctly filters rows where manager_id has a value.

Select Statement#162

Which statement is true regarding distinct keywords?

A
DISTINCT removes duplicate values in the SELECT clause.
B
DISTINCT can be used multiple times in a SELECT statement.
C
DISTINCT applies only to numeric columns.
D
DISTINCT and UNIQUE are different keywords.

DISTINCT eliminates duplicate rows from the query result.

Select Statement#163

You need to remove all the data from the employee table while leaving the table definition intact. You want to be able to undo this operation. How would you accomplish this task?

A
DELETE FROM employee;
B
TRUNCATE TABLE employee;
C
DROP TABLE employee;
D
ALTER TABLE employee;

DELETE is DML and can be rolled back; TRUNCATE cannot be rolled back.

Select Statement#164

Which option is used to delete data from both parent and child tables?

A
CASCADE
B
RESTRICT
C
SET NULL
D
NO ACTION

ON DELETE CASCADE automatically deletes child records when the parent is deleted.

Select Statement#165

How do we represent comments in oracle?

A
/* */ and --
B
// and /* */
C
# and --
D
<!-- --> and //

Oracle SQL supports /* */ for block comments and -- for single-line comments.

Select Statement#166

Which query will change the cust_address to 'Panama' for those who are from ‘Los Angeles’?

A
UPDATE customer SET cust_address = 'Panama' WHERE cust_address = 'Los Angeles';
B
UPDATE customer SET cust_address = 'Los Angeles' WHERE cust_address = 'Panama';
C
INSERT INTO customer (cust_address) VALUES ('Panama');
D
DELETE FROM customer WHERE cust_address = 'Los Angeles';

UPDATE with SET and WHERE clause changes the specified rows.

Select Statement#167

Which statement is used to update multiple rows in a single query?

A
WHERE clause (no additional keyword needed)
B
AND
C
WHEN
D
IN

A single UPDATE with a WHERE clause can update multiple rows simultaneously without extra keywords.

Select Statement#168

A DML statement is used to modify the structure of the database. State True or false.

A
TRUE
B
FALSE

Refer to Database Management — Select Statement study materials.

Select Statement#169

Which statements are true regarding constraints?

A
A column with the UNIQUE constraint can contain NULL values.
B
A foreign key cannot contain NULL values.
C
A constraint is enforced only for the INSERT operation.
D
A constraint cannot be disabled when the column contains data.

UNIQUE constraints allow NULL values (a NULL is not considered equal to another NULL).

Select Statement#170

Which query will delete all the data in the Employee table that belongs to the employee id 1207?

A
DELETE FROM Employee WHERE emp_id = 1207;
B
DROP FROM Employee WHERE emp_id = 1207;
C
TRUNCATE Employee WHERE emp_id = 1207;
D
REMOVE FROM Employee WHERE emp_id = 1207;

DELETE with a WHERE clause removes specific rows matching the condition.

Select Statement#171

Create table subjects(Sub_id number(2) primary key,Subj_name varchar(50)); Insert into subjects values (null,’Oracle’); What will be the output of the given query?

A
The query will generate an ORA-01400: cannot insert NULL into primary key.
B
The query will execute successfully.
C
The query will insert a NULL value as stud_id.
D
The query will generate a duplicate key error.

Primary key columns cannot be NULL; omitting Sub_id causes ORA-01400.

Select Statement#172

Which statement is true when a DROP TABLE command is executed on a table?

A
The table structure and its data cannot be rolled back and restored once DROP TABLE is executed.
B
The DROP TABLE command can be executed on a table with pending transactions.
C
Only a DBA can execute the DROP TABLE command.
D
The data can be rolled back after DROP TABLE.

DROP TABLE is DDL — it auto-commits and is irreversible without a backup.

Key Topics to Study

Based on our question bank analysis, master these concepts to score high in Database Management.

SQLTableConstraintJoinQueryInsertDeleteAggregate
Preparation Tip

"Focus on understanding the logic behind pseudocode loops and selection statements, as they form the bulk of technical assessments."