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
-
In compiled form
-
As source code
-
Both A & B
-
Not stored
C
Correct answer
Explanation
Database procedures (like PL/SQL in Oracle) are stored in compiled form for performance, but the source code is also retained for debugging and modification purposes. Most database systems store both representations.
-
Check whether cursor has fetched any row
-
Check whether cursor has not fetched any row.
-
Check the number of rows returned by the cursor
-
Both A and C
C
Correct answer
Explanation
The %ROWCOUNT cursor attribute returns the number of rows fetched by the cursor so far. It's commonly used to check if any rows were returned or to iterate through results.
-
user defined
-
implied
-
implicit and explicit
-
Implied and user defined
C
Correct answer
Explanation
PL/SQL has two types of cursors: implicit cursors (automatically created by Oracle for SQL statements like SELECT) and explicit cursors (declared and managed by the programmer for finer control over row processing). The terminology is 'implicit' and 'explicit', not 'implied' or 'user defined'.
-
Use the bcp command
-
Use the BULKINSERT statement
-
Create a custom format file
-
None of the above
A
Correct answer
Explanation
Both bcp (Bulk Copy Program command-line utility) and BULK INSERT (T-SQL statement) can import data from text files into SQL Server. The bcp utility is commonly used for batch file processing and is well-suited for automated imports from external sources like store transaction files. BULK INSERT is equally valid but is T-SQL based. Given the scenario of receiving files from multiple stores, bcp is a reasonable choice for command-line batch processing.
-
System Function
-
Stored procedure
-
User-Defined-Function
-
Views
-
Unique Index
-
Clustered Index
-
Non-Clustered Index
-
Foreign Key
B
Correct answer
Explanation
A clustered index physically sorts and stores the data rows in the table based on the index key. This means the table's actual data on disk is arranged in the order of the clustered index columns. Each table can have only one clustered index because the data can only be physically stored in one order. Non-clustered indexes create separate structures that point to the actual data.
-
Structured Query Language
-
Strong Question Language
-
Structured Question Language
-
none of above
A
Correct answer
Explanation
SQL stands for Structured Query Language, the standard language for managing and manipulating relational databases. It's used for querying, updating, and managing data in database systems. Options B and C incorrectly use 'Question' instead of 'Query'.
C
Correct answer
Explanation
The SELECT statement is the fundamental SQL command used to retrieve and extract data from database tables. It allows you to specify which columns and rows you want to retrieve. Options A, B, and D are not valid SQL statements for data retrieval.
-
DELETE
-
COLLAPSE
-
REMOVE
-
None
A
Correct answer
Explanation
The DELETE statement is used to remove rows from a database table. You can delete specific rows using a WHERE clause or all rows if no condition is specified. Options B (COLLAPSE) and C (REMOVE) are not valid SQL statements.
C
Correct answer
Explanation
The SELECT statement is used to extract or retrieve data from a database. It's the primary query command in SQL that allows you to specify columns and conditions for data retrieval. Options A (OPEN), B (GET), and D (EXTRACT) are not correct SQL statements for querying data.
-
SAVE
-
SAVE AS
-
MODIFY
-
UPDATE
D
Correct answer
Explanation
The UPDATE statement is used to modify existing data in a database table. It allows you to change values in specific columns for rows that match a given condition. Options A (SAVE), B (SAVE AS), and C (MODIFY) are not valid SQL statements for updating data.
-
INSERT NEW
-
ADD RECORD
-
ADD NEW
-
INSERT INTO
D
Correct answer
Explanation
The standard SQL statement used to add new records to a database table is 'INSERT INTO'. 'INSERT NEW', 'ADD RECORD', and 'ADD NEW' are syntactically invalid in standard SQL.
-
SELECT Persons
-
SELECT *.Persons
-
SELECT * FROM Persons
-
SELECT [all] FROM Persons
C
Correct answer
Explanation
To select all columns from a table, you use SELECT * followed by FROM and the table name. The asterisk () is a wildcard that represents all columns in the table. Option A only selects the table name (not columns), B has incorrect syntax (.Persons), and D uses non-existent [all] syntax.
-
SELECT * FROM Persons WHERE FirstName<>'Peter'
-
SELECT [all] FROM Persons WHERE FirstName='Peter'
-
SELECT * FROM Persons WHERE FirstName='Peter'
-
SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
C
Correct answer
Explanation
To select records where a column equals a specific value, use SELECT * FROM table WHERE column='value'. The correct syntax uses single quotes for string values and the equals operator. Option A uses <> (not equals), B uses invalid [all] syntax, and D uses LIKE which is for pattern matching, not exact matches.