WorksheetsDBMS Quiz
Total questions: 68
Worksheet time: 13mins
What does DBMS stand for?
Database Management Solution
Data Backup Management System
Database Management System
Data Business Management Software
Which of the following is a DBMS software?
MS Word
MySQL
Photoshop
Notepad
Which of the following is not a function of DBMS?
Data storage
Data backup
Data manipulation
Graphic design
Which language is used to define the structure of a database?
DML
DDL
HTML
SQL
Which of the following is NOT a DDL command in SQL?
CREATE
UPDATE
ALTER
DROP
What does the ALTER command do in SQL?
Adds, deletes, or modifies columns in a table
Removes a table completely
Changes existing data in rows
Creates a new database
Who is responsible for managing the database system?
Web Developer
System Analyst
Database Administrator
Data Miner
Which one of the following is a type of key in DBMS?
Main key
Primary key
Start key
Index key
Which of these ensures uniqueness in a database table?
Column
Foreign key
Primary key
Row
The full form of SQL is:
Structured Question Language
Standard Query List
Structured Query Language
Sequential Query Language
Which of these is NOT a feature of DBMS?
Concurrency
Redundancy
Security
Data integrity
A DBMS reduces:
Data retrieval
Data redundancy
Storage speed
System updates
Which of the following is a DML command?
CREATE
INSERT
DROP
ALTER
Which of the following best defines a tuple?
A column
A table
A row
A schema
A database schema is a:
Plan for a website
Framework of a database
Set of queries
Data set
Which command will remove a table completely along with its structure and data?
DELETE
DROP
TRUNCATE
REMOVE
The command to change the name of a table is:
RENAME
ALTER TABLE RENAME TO
MODIFY
UPDATE
Which of the following cannot be rolled back once executed?
DELETE
TRUNCATE
DROP
Both B and C
To add a new column to an existing table, which command is used?
UPDATE TABLE
ALTER TABLE ADD
CREATE COLUMN
INSERT COLUMN
A foreign key is used to:
Delete records
Link two tables
Encrypt data
Identify a table uniquely
Which of the following is true for a primary key?
Can have NULL values
May not be unique
Can consist of multiple columns
Used only for foreign tables
Which of the following is a constraint in DBMS?
WHERE clause
DEFAULT value
CHECK
FROM clause
In relational DBMS, relationships are implemented through:
Loops
Foreign keys
Nested queries
Triggers
Which of the following is NOT an integrity constraint?
Entity integrity
Referential integrity
File integrity
Domain constraint
Which is NOT a feature of PL/SQL?
Block structure
Exception handling
Modular programming
GUI building
Which section of PL/SQL block is optional?
DECLARE
BEGIN
END
None
A variable name in PL/SQL can be up to:
100 chars
50 chars
30 chars
Unlimited
Which of these is an invalid variable name?
salary$
v2_num
1value
v_name
Syntax to declare a variable in PL/SQL:
name data_type;
variable name type;
datatype name;
name := datatype;
Local variables in nested blocks:
Are accessible in outer blocks
Are not accessible in outer blocks
Can be used anywhere
Automatically global
Keyword to declare constant:
CONST
CONSTANT
FIXED
IMMUTABLE
Which is a logical operator in PL/SQL?
AND
OR
NOT
All of the above
Which is NOT a valid IF form in PL/SQL?
IF-THEN
IF-THEN-ELSE
IF-THEN-ELSIF ladder
IF-ONLY
In PL/SQL, a FOR loop counter increments by:
Default 2
Default 1
Must specify explicitly
Cannot decrement
Which loop requires explicit EXIT?
FOR loop
WHILE loop
Simple LOOP
None
(Code)
DECLARE
fact NUMBER := 1;
BEGIN
FOR i IN 1..4 LOOP
fact := fact * i
; END LOOP;
DBMS_OUTPUT.PUT_LINE(fact); END; /
10
24
120
Error
%TYPE is used to:
Match data type of a column/variable
Match whole row
Declare trigger type
None
%ROWTYPE is used to:
Define multiple rows
Define structure same as table/cursor row
Define constants
None
(Code) DECLARE vEmployeeName Employee.Name%TYPE;
BEGIN SELECT Name INTO vEmployeeName FROM Employee WHERE ROWNUM = 1; DBMS_OUTPUT.PUT_LINE(vEmployeeName);
END; /
NUMBER
VARCHAR2
Employee.Name column
Table row
VARRAY is used to store:
Heterogeneous data
Ordered homogeneous collection
Random rows from DB
Only character data
VARRAY elements are stored:
Randomly
In contiguous memory
In temporary table
On disk
(Code) TYPE grades IS VARRAY(5) OF INTEGER;
Array of 5 characters
Array of 5 integers
Array of 5 rows
None
A view in SQL is:
A physical table
A logical/virtual table based on a query
A synonym for a table
A stored procedure
Which option allows view creation even if base table doesn't exist?
NOFORCE
FORCE
OR REPLACE
WITH READ ONLY
Which option makes a view unmodifiable?
FORCE
WITH CHECK OPTION
WITH READ ONLY
OR REPLACE
Which statement deletes a view permanently?
REMOVE VIEW v1;
DROP VIEW v1;
DELETE VIEW v1;
TRUNCATE VIEW v1;
Code Output: CREATE VIEW emp_view AS SELECT emp_id, emp_name FROM employees;
INSERT INTO emp_view VALUES (101, 'Ravi');
SELECT * FROM emp_view;
Output = ?
Error - cannot insert into view
Row inserted: (101, Ravi)
No rows displayed
Only emp_id shown
Which statement is TRUE about procedures?
Must always return a value
Cannot accept parameters
Can have IN, OUT, IN OUT parameters
Are temporary blocks only
In procedure creation, `AS` can replace which keyword?
IS
RETURN
DECLARE
BEGIN
Parameter mode used to send data into procedure:
IN
OUT
IN OUT
RETURN
Code Output: DECLARE v_name VARCHAR2(20) := 'Alfred';
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello ' || v_name);
END; / Output = ?
Hello
Alfred
Hello Alfred
Error
Code Output: DECLARE
n NUMBER := 4;
fact NUMBER := 1;
BEGIN FOR i IN 1..n LOOP
fact := fact * i;
END LOOP; DBMS_OUTPUT.PUT_LINE('Factorial = ' || fact);
END; /
Output = ?
Factorial = 16
Factorial = 24
Factorial = 4
Error
Code Output:
DECLARE num NUMBER := 12;
BEGIN
IF MOD(num, 2) = 0 THEN
DBMS_OUTPUT.PUT_LINE(num || ' is Even');
ELSE DBMS_OUTPUT.PUT_LINE(num || ' is Odd');
END IF; END; /
Output = ?
12 is Odd
12 is Even
Error
Null
Code Output: DECLARE
n NUMBER := 5;
BEGIN FOR i IN 1..3 LOOP
DBMS_OUTPUT.PUT_LINE(n || 'x' || i || '=' || (n*i)); END LOOP; END; /
Output = ?
5x1=5, 5x2=10, 5x3=15
5, 10, 15
Error
Null
Code Output: DECLARE str VARCHAR2(50) := 'Hello World'; v_count NUMBER := 0; ch CHAR(1); BEGIN FOR i IN 1..LENGTH(str) LOOP ch := SUBSTR(str, i, 1); IF LOWER(ch) IN ('a','e','i','o','u') THEN v_count := v_count + 1; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE('Vowels: ' || v_count); END; / Output = ?
Vowels: 2
Vowels: 3
Vowels: 4
Error
Which keyword is used to execute a standalone procedure?
EXECUTE
EXEC
BEGIN-END block
All of the above
Procedures are stored in:
User's local memory
Database schema
Only inside triggers
Only inside packages
In PL/SQL, factorial of 0 is returned as:
Error
0
1
NULL
A function must have:
OUT parameter
RETURN statement
Exception block
Cursor
Which statement is valid for default parameter assignment?
p NUMBER = 5
p NUMBER := 5
p DEFAULT 5
p OUT NUMBER := 5
Code Output: DECLARE n NUMBER := 8; result NUMBER; BEGIN result := n * n; -- Square logic DBMS_OUTPUT.PUT_LINE(result); END; / Output = ?
8
16
64
Error
Code Output: DECLARE price NUMBER := 400; disc NUMBER; BEGIN -- Suppose discount = 5% of price disc := price * 0.05; DBMS_OUTPUT.PUT_LINE(disc); END; / Output = ?
5
20
400
0
Code Output: DECLARE qty NUMBER := 25; rate NUMBER := 4; total NUMBER; BEGIN total := qty * rate; -- multiplication DBMS_OUTPUT.PUT_LINE(total); END; / Output = ?
0
100
29
Error
Functions can be called from:
SELECT statements
PL/SQL blocks
Expressions
All of the above
What happens if a function does not contain a RETURN statement?
It runs normally
Compilation error
Returns NULL
Infinite loop
Which keyword is used for exception handling in functions?
TRY
CATCH
EXCEPTION
ERROR
Functions must always return:
At least one OUT parameter
Exactly one value
Multiple values
Nothing
Which of the following can be reused both in SQL and PL/SQL blocks?
Views only
Procedures only
Functions
None
