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. 03-JUL-00

  2. 10-JUL-00

  3. 12-JUL-00

  4. 11-JUL-00

  5. 17-JUL-00

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The NEXT_DAY function returns the first occurrence of a specified weekday that comes AFTER the current date. Since today is Monday, July 10, NEXT_DAY looks for the NEXT Monday, which is July 17. It doesn't return the current day, but the following instance of that weekday.

Multiple choice technology databases
  1. 8

  2. 2

  3. 3

  4. 4

  5. THERE IS NO SUCH CRITERIA

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

When joining n tables in Oracle (or most SQL databases), you need at least n-1 join conditions to avoid Cartesian products between the tables. For 4 tables, this means at least 3 join conditions. Each condition links one table to another, creating a chain that connects all tables.

Multiple choice technology programming languages
  1. 1

  2. 2

  3. 3

  4. 0

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The SQL concatenation operator || joins multiple column values into a single result column. This query combines name, age, and address with comma separators, creating exactly one output column named 'emp_details'. The number of source columns concatenated doesn't affect the result column count.

Multiple choice technology programming languages
  1. Full table scan

  2. Table access by ROWID

  3. Access via unique index

  4. Primary key access

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Accessing a row by its physical address (ROWID) is the fastest access path in Oracle. It allows Oracle to locate the row directly on disk in a single read. Other methods like index lookups or primary key access require searching the index structure first to find the ROWID.

Multiple choice technology programming languages
  1. DROP

  2. TRUNCATE

  3. DELETE

  4. CASCADE

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The TRUNCATE command is a DDL statement that removes all rows from a table immediately. Because it is DDL, it commits automatically and does not write individual row deletes to the rollback segment, making it faster than DELETE. DROP deletes the table structure entirely.

Multiple choice technology databases
  1. Row level DML trigger

  2. Statement level DML trigger

  3. Row level Application trigger

  4. Statement level Application trigger

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

OLD and NEW qualifiers (referencing :OLD and :NEW values) are only available in row-level DML triggers. These qualifiers reference the before/after state of the row being modified. Statement-level triggers operate on sets of rows and don't have :OLD/:NEW context. Application triggers (Forms/Reports) have different mechanisms.

Multiple choice technology databases
  1. Package

  2. Stored Function

  3. Stored Procedure

  4. Another Trigger

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A CALL statement within a database trigger is used to invoke stored procedures. Triggers can execute stored procedures to perform complex operations that cannot be done with simple SQL statements. Packages are schema objects that group related procedures, functions, and variables, while stored functions return values and cannot be called with CALL in most database systems.

Multiple choice technology databases
  1. VARCHAR2

  2. BOOLEAN

  3. IN

  4. OUT

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

OUT parameters are specifically designed to pass values back from a procedure to the calling environment. IN parameters pass values into the procedure but cannot return values. VARCHAR2 and BOOLEAN are data types, not parameter modes. The OUT mode allows the procedure to send computed results back to the caller.

Multiple choice technology architecture
  1. Using aliases

  2. Removing extra joins

  3. Using Contexts

  4. A loop cannot be removed

Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

Loops in universe schema design occur when multiple join paths exist between tables. Aliases create alternate table references to break loops by providing unique paths. Contexts define separate logical paths for different query scenarios. Option B is incorrect because removing joins would break required relationships.

Multiple choice technology databases
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

SQL Server 2005 supports renaming databases and database objects through the sp_rename system stored procedure. This procedure can rename tables, views, stored procedures, indexes, columns, and other user-created objects. However, some system objects and certain object types have restrictions on renaming.

Multiple choice technology databases
  1. (a) Use the bcp command

  2. (b) Use the BULKINSERT statement

  3. (c) Create a custom format file

  4. (d) None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The bcp (Bulk Copy Program) utility is specifically designed for bulk importing data from text files into SQL Server. It's a command-line tool optimized for high-volume data transfer and handles various text formats. BULK INSERT is a T-SQL statement that performs similar function but requires the file to be accessible from the server. Both are valid, but bcp is the most direct answer for 'receiving text files' that need import. Custom format files are used with both bcp and BULK INSERT to define column mappings, not a standalone solution.

Multiple choice technology databases
  1. (a) Text

  2. (b) Varbinary

  3. (c) Varchar(max)

  4. (d) Varchar

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

VARCHAR(max) is the correct data type for storing up to 2 GB of text in SQL Server 2005. The TEXT data type is deprecated and doesn't support standard string functions and operators directly - you need to use READTEXT/WRITETEXT. VARCHAR(max) allows you to use all standard string functions and operators. VARCHAR without (max) has a maximum of 8000 characters. VARBINARY(max) is for binary data, not text.

Multiple choice technology databases
  1. (a) Create index

  2. (b) Alter database

  3. (c) Insert data

  4. (d) Restore Database

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Among the operations listed, only Insert data (C) is allowed inside a trigger. Triggers execute in response to DML operations (INSERT, UPDATE, DELETE) and can themselves perform data modifications. CREATE INDEX, ALTER DATABASE, and RESTORE DATABASE are DDL operations that are not permitted within a trigger because triggers execute as part of the DML transaction and these DDL operations would break transactional integrity or require exclusive locks.