Computer Knowledge
Database and SQL
3,929 Questions
Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.
SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions
Database and SQL Questions
-
Single table
-
Multiple table
-
Non-existing tables
-
Triggers
-
None of these
C
Correct answer
Explanation
Forced view is used for the table, which are not created. This concept is required for bigger programs, where many people are working on the same project.
-
dbms_output.put_line ('Text');
-
dbms-output.put-line ('Text');
-
dbms_output ('Text');
-
printf (Text);
-
puts(Text);
A
Correct answer
Explanation
This is the correct syntax of the function used to print on screen.
-
single variable
-
entire row of a table
-
entire column of a table
-
entire table
-
multiple row
B
Correct answer
Explanation
%rowtype is used to select entire row of a table. It does not consider the datatype of the individuals cells.
-
Select * from emp where not Job = 'Manager';
-
Select * from emp where Job != 'Manager;
-
Select * from emp where Job <> 'Manager';
-
Select * from emp where Job not in ('Manager');
-
Select * from emp where Job in ('Manager');
E
Correct answer
Explanation
This will give all data of emp table only where Job is Manager.
-
Select ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;
-
Select ENAME, SAL, SAL* 10 10% INCREASED SAL from emp;
-
Select ENAME, SAL, SAL* 0.01 '10% INCREASED SAL' from emp;
-
Find ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;
-
Seek ENAME, SAL, SAL* 0.1 10% INCREASED SAL from emp;
A
Correct answer
Explanation
This is the correct SQL statement to find the specified fields with the virtual column.
-
Insert
-
Update
-
Delete
-
Select
-
Create
-
Characters enclosed within single quotes
-
Date datatypes enclosed within single quotes
-
NULL values are written as NULL.
-
Number data not to be enclosed in single quotes
-
If some columns are fed with values, then rest will be assigned zero
E
Correct answer
Explanation
Rest will be assigned with NULL.
-
% is open
-
% found
-
% not found
-
% row count
-
% cursor
E
Correct answer
Explanation
It is not a cursor attribute.
-
The line numbers reported match the line numbers you see in your text editor.
-
SQL*Plus will automatically show the errors to you.
-
To see the errors, enter SHOW ERRORS in SQL*Plus.
-
If there are no syntax errors, you will receive the message "NO ERRORS."
C
Correct answer
Explanation
When a PL/SQL procedure has compilation errors, SQL*Plus displays a warning message but does not automatically show the errors. The DBA or developer must explicitly execute the 'SHOW ERRORS' command to view the compilation error details, including line numbers and error messages. Option A is incorrect because SQL*Plus renumbers lines starting from 1, not matching your editor. Option B is false because errors aren't shown automatically. Option D is incorrect - successful compilation produces no warning message.
-
A left slash ( ) followed by [Enter].
-
A colon ( : ) followed by [Enter].
-
A semicolon ( ; ) followed by [Enter].
-
A period ( . ) followed by [Enter].
C
Correct answer
Explanation
In SQL*Plus, a semicolon followed by the Enter key signals that the SQL statement is complete and ready for execution. The semicolon acts as a statement terminator in SQL*Plus. Option A is incorrect - a forward slash (/) executes statements in the buffer but doesn't terminate statement entry. Option B's colon is used for bind variables, not statement termination. Option D's period has no special meaning in SQL*Plus statement termination.
-
UPDATE TABLE [TableName].
-
MODIFY TABLE [TableName].
-
ALTER TABLE [TableName].
-
CHANGE TABLE [TableName].
C
Correct answer
Explanation
ALTER TABLE is the standard SQL command for modifying the structure of an existing table. This includes adding, dropping, or modifying columns, constraints, and other table properties. UPDATE TABLE is used for modifying data within a table, not its structure. MODIFY TABLE and CHANGE TABLE are not valid SQL commands in any major database system.
-
are case insensitive.
-
are case sensitive.
-
must always be in lower case.
-
must always be in upper case.
A
Correct answer
Explanation
SQL*Plus and Oracle database identifiers are case-insensitive by default. This means 'SELECT', 'select', and 'Select' are treated identically, and table/column names like 'Employee' and 'employee' refer to the same object. This case-insensitivity applies unless quoted identifiers are used, in which case they become case-sensitive. The default behavior makes SQL*Plus more user-friendly and less prone to typing errors.
-
a left slash ( ) followed by [Enter]
-
a colon ( : ) followed by [Enter]
-
a semicolon ( ; ) followed by [Enter]
-
a period ( . ) followed by [Enter]
C
Correct answer
Explanation
The semicolon is the standard SQL statement terminator in SQL*Plus. When you type a semicolon and press Enter, SQL*Plus recognizes the statement as complete and executes it. The forward slash (/) is used to execute the contents of the SQL buffer, not terminate a new statement. The colon (:) is used for bind variables in SQL*Plus. The period (.) is used in some SQL implementations but not in Oracle SQL*Plus for statement termination.
-
EMPNO ,unique value of ENAME and then SALARY are displayed.
-
EMPNO ,unique value of the two columns, ENAME and salary are displayed.
-
DISTINCT is not a valid keyword in SQL.
-
No values will be displayed because the statement will return an error.
D
Correct answer
Explanation
The query will return an error because DISTINCT cannot be used for individual columns in a SELECT statement - it must apply to all selected columns or the entire row. The syntax 'select enpno, DISTINCT ename, Salary' is invalid because DISTINCT must come before the column list and apply to the combination of all columns, not just one column.
-
Enabled
-
Database Item
-
Update Allowed
-
Update Only If NULL
D
Correct answer
Explanation
The 'Update Only If NULL' property ensures that a field can only be updated when it has no value (is NULL). Once a value is entered, it cannot be modified. This is perfect for the shipping date scenario - clerks can enter the date initially, but once saved, it becomes read-only. 'Enabled' controls whether the item can receive focus, 'Database Item' indicates if it's stored in the database, and 'Update Allowed' is a binary on/off setting.