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

Multiple choice technology databases
  1. In compiled form

  2. As source code

  3. Both A & B

  4. Not stored

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. Check whether cursor has fetched any row

  2. Check whether cursor has not fetched any row.

  3. Check the number of rows returned by the cursor

  4. Both A and C

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. user defined

  2. implied

  3. implicit and explicit

  4. Implied and user defined

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice technology web technology
  1. Use the bcp command

  2. Use the BULKINSERT statement

  3. Create a custom format file

  4. None of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Unique Index

  2. Clustered Index

  3. Non-Clustered Index

  4. Foreign Key

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Structured Query Language

  2. Strong Question Language

  3. Structured Question Language

  4. none of above

Reveal answer Fill a bubble to check yourself
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'.

Multiple choice technology databases
  1. OPEN

  2. GET

  3. SELECT

  4. EXTRACT

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SAVE

  2. SAVE AS

  3. MODIFY

  4. UPDATE

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SELECT Persons

  2. SELECT *.Persons

  3. SELECT * FROM Persons

  4. SELECT [all] FROM Persons

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName<>'Peter'

  2. SELECT [all] FROM Persons WHERE FirstName='Peter'

  3. SELECT * FROM Persons WHERE FirstName='Peter'

  4. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

Reveal answer Fill a bubble to check yourself
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.