Computer Knowledge
Database and SQL
4,213 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
-
SELECT SYSDATE+1 FROM DUAL
-
SELECT TO_CHAR(SYSDATE+1,'MM/dd/yyyy HH:mm:ss') FROM DUAL
-
SELECT SYSDATE+1/86400 FROM DUAL
-
SELECT (SYSDATE+1)/86400 FROM DUAL
C
Correct answer
Explanation
This answer is correct. SYSDATE+1 will give the next date and time component. But SYSDATE+1/86400 will give the next second of the current date and current hour and current minute because in a given day, there are 86400 seconds, i.e. 24 * 60 * 60 seconds. Hence 1/86400 will give you the current second. When the sysdate is added to 1/86400, it gives the next second of the current date, hour and minute.
-
getMaxColumnsInGroupBy()
-
getMaxColsInGroupBy()
-
getMaxColumnInGroupBy()
-
getMaxGroupByColumns()
-
getMaxColumnsAllowedInGroupBy()
A
Correct answer
Explanation
This is the correct choice. getMaxColumnsInGroupBy() method is present in the DatabaseMetaData interface in Java.
-
Char
-
Varchar
-
Number
-
Integer
-
Date
D
Correct answer
Explanation
Integer is not an oracle datatype.
A
Correct answer
Explanation
10/3 = 3 and reminder is 1, which is mod.
-
Given after all column definition.
-
Composite constraints can be given.
-
Not NULL cannot be given.
-
Columns can be compared with each other.
-
None of these
E
Correct answer
Explanation
Since all other options are correct for Table level constraints, therefore, this is the correct option.
-
Table joins to itself.
-
Used to handle self referential integrity.
-
The table is logically divided and table alias are used.
-
Table appears twice in the from clause following their alias.
-
None of these
-
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.