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
-
Delete
-
Select
-
Create
-
Insert
-
Update
C
Correct answer
Explanation
Create is a DDL statement as this statement defines the structure of a database.
-
TRIGGER
-
CREATE VIEW
-
UPDATE
-
GRANT
-
REVOKE
E
Correct answer
Explanation
The REVOKE command revokes previously granted privileges from one or more roles.
-
REVOKE
-
DROP
-
INSERT
-
GRANT
-
ALTER
D
Correct answer
Explanation
SQL GRANT is a command used to provide access or privileges of the database objects to other users.
-
CREATE TRIGGER
-
CREATE VIEW
-
CREATE TABLESPACE
-
GRANT
-
CREATE SYNONYM
A
Correct answer
Explanation
This option is correct as CREATE TRIGGER command is a SQL statement that creates a trigger to the database schema.
A
Correct answer
Explanation
This option is correct as AVG is a predefined SQL function that is used to calculate the average of a given record.
-
ALTER
-
ROLLBACK
-
GRANT
-
DROP
-
REVOKE
B
Correct answer
Explanation
This option is correct as transaction control commands manage the changes made by data manipulation commands.
-
WHERE
-
DISTINCT
-
SELECT
-
LIKE
-
GROUP BY
B
Correct answer
Explanation
This option is correct as this distinct keyword selects only those values that are unique.
-
PRIMARY KEY
-
FOREIGN KEY
-
COMPOSITE KEY
-
ALTERNATE KEY
-
DEFAULT
A
Correct answer
Explanation
This option is correct as primary key constraint does not allow duplicacy of data. Hence, it uniquely identifies each row in the table.
-
Alter table
-
Resize
-
Drop
-
Change Size
A
Correct answer
Explanation
The alter statement is used to resize a column. The size of a column can both be increased or decreased using the alter keyword. Normally, the size of a column can be increased to a large value but it can only be decreased to the limit that if there is data present in the column, it should not get trimmed.
-
Structured Question Lanaguage
-
Strurctured Queried Language
-
Structured Query Language
-
Structured Queries Language
C
Correct answer
Explanation
It is the language to handle basic database operations like creating a table and managing it. Some of the keywords of SQL are Create,Select, Delete, Update etc.. SQL is also sometimes called SEQUEL which stands for Simple English Like Query Language. SQL is supported by all the major RDBMS products like Oracle, Ms-SQL Server, MySQL to name a few.
-
& and *
-
% and *
-
% and _ (underscore)
-
$ and _ (underscore)
C
Correct answer
Explanation
The Like operator is used for pattern matching in VARCHAR columns. It is useful in conditions where we do not to compare a value exactly with another. For example, if we want to search for all the persons whose names start with A, we can use the Like operator with the wildcard character. % is used for substituting a string. For conducting a character replacement we can use the _ (underscore) operator. It is used for matching values that are of a particular length.
-
Select * from tables
-
Select * from tab
-
Select * from tabs
-
Select all from tab
B
Correct answer
Explanation
The above statement is a valid statement and will display a list of tables available in a user's account. The statement will also print the names of the available view, synonyms etc. The select * from tab statement actually queries a synonym named tab which is in the System user account. All the users created in Oracle have a default access to the synonym. Therefore when we are issuing the above statement we are in fact querying the said synonym.
-
Undo
-
Recover
-
Rollback
-
Recall
C
Correct answer
Explanation
Rollback is a part of Transaction Control Language or (TCL). It is used to cancel or undo any changes made in a table. For example, it the user has accidently deleted the data, it can be easily rollbacked to the previous state. The other commands of the same category (TCL) are commit, savepoint etc.
-
view
-
object
-
synonym
-
alias
D
Correct answer
Explanation
Alias is the temporary name given to a table or a column. An alias is quite useful where the name of the table is lengthy and the name has to be written more than once in a statement. A table alias is generally a word with one or two letters that can substitute a table name. For example, if the name of a table is sales_1999, then instead of writing sales_1999 everytime it is required, we can create an alias an use it. Consider the following statement: Select s.data from sales_1999 where s.no=101 in the above statement. S is an alias and it is used as a substitution for the word sales_1999.
-
deletes all the records from a table
-
deletes all the rows along with the table
-
deletes the structure of the table leaving rows intact
-
deletes only the null rows of a table
A
Correct answer
Explanation
The Truncate Table statement is used to delete all the rows of a table at once. The statement allows the user to delete all the records without specifying a condition using the where clause. Truncate deletes all the records but keeps the structure of the table intact. The output of this statement is equivalent to the delete statement without the where statement.