Computer Knowledge

Database and SQL

3,929 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 web technology
  1. GetSqlValue ()

  2. GetOrdinal ()

  3. GetName ()

  4. all the above

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

GetName(int ordinal) returns the column name for a given zero-based position ordinal in DataReader. GetOrdinal is the inverse (name -> ordinal). GetSqlValue gets value as SqlTypes. GetName() is specifically for getting column names.

Multiple choice technology web technology
  1. auto.AutoIncrementSeed = 1

  2. auto.AutoIncrement = true

  3. auto.Increment = true;

  4. auto.IncrementSeed = 1;

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

Setting AutoIncrement=true enables auto-increment for a DataColumn. The other options use incorrect property names or syntax. However, a complete implementation would also set AutoIncrementSeed and AutoIncrementStep properties. The question asks about basic enabling.

Multiple choice technology web technology
  1. SqlDataReader

  2. SqlConnection

  3. SqlCommand

  4. SqlClientPermissionAttribute

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

In ADO.NET, SqlConnection establishes the connection, SqlCommand executes queries, and SqlDataReader retrieves the read-only stream of data from a SQL Server database. All of these classes are essential components of the System.Data.SqlClient namespace.

Multiple choice technology web technology
  1. The Physical Data Store

  2. The DataSet

  3. The Data Provider

  4. All the above

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

ADO.NET has three logical layers: Physical Data Store (database), DataSet (in-memory cache), and Data Provider (bridge between them - Connection, Command, DataAdapter, DataReader). All three layers are essential components.

Multiple choice technology web technology
  1. SqlConnection conn = new SqlConnection(

  2. SqlConnection conn=null; conn=new SqlConnection(

  3. SqlConnection conn = SqlConnection(

  4. All the above

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

Option A shows the standard one-line declaration and instantiation of SqlConnection. Option B demonstrates two-step initialization: first declaring null, then assigning with new keyword. Both are valid C# syntax patterns. Option C is incorrect because it omits the 'new' keyword required for object instantiation.

Multiple choice technology web technology
  1. SqlDataReader rdr = cmd.ExecuteReader();

  2. SqlDataReader rdr = ExecuteReader();

  3. SqlDataReader rdr = cmd.Execute();

  4. SqlDataReader rdr = cmd.ExecuteScalar();

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

SqlDataReader is created by calling ExecuteReader() on a SqlCommand object. Option A correctly shows this pattern with cmd.ExecuteReader(). Options B, C, and D are incorrect: B omits the command object, C uses Execute() which returns a boolean, D uses ExecuteScalar() which returns a single value, not a reader.

Multiple choice technology web technology
  1. Close connection

  2. Open connection

  3. Retrieve data into DataSet

  4. Write changes from DataSet to data source

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

SqlDataAdapter automatically handles connection lifecycle during Fill() operations: it opens the connection if closed (B), retrieves data into the DataSet (C), and returns the connection to its original state (closed if it was closed). Option D is incorrect because WriteChanges from DataSet to data source requires separate Update() method, not Fill().

Multiple choice technology packaged enterprise solutions
  1. Type is Data (Private)

  2. Always prefixed with ‘X_’

  3. Provided by Siebel for Developers use

  4. Cannot be edited

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

Standard Extension database columns in Siebel are custom columns that developers can add to extend base tables. They are always prefixed with 'X_' to distinguish them from standard Siebel columns. Option B is correct: they are prefixed with 'X_'. Option A is incorrect (type is not private data), Option C is misleading (they are for developer use but not provided by Siebel), Option D is incorrect (they can be edited).

Multiple choice technology packaged enterprise solutions
  1. S_PERSON

  2. S_EMP_PER

  3. S_USER

  4. S_CONTACT

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

Person-related data in Siebel is stored in the S_CONTACT table, which is the base table for contact information including both internal employees and external contacts. S_PERSON is not a standard table, S_EMP_PER is for employee-specific data, and S_USER is for user authentication.

Multiple choice technology databases
  1. SELECT text FROM user_source WHERE name ='SALARY_CALC';

  2. SELECT * FROM user_source WHERE source_name ='salary_calc';

  3. SELECT * FROM user_objects WHERE object_name = 'SALARY_CALC';

  4. SELECT text FROM user_source WHERE name='SALARY_CALC' AND owner ='JOHN';

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

To solve this question, the user needs to know the structure of the system tables in Oracle database where all the objects are stored.

Option A is correct. This query will return the text of the procedure SALARY_CALC. The user_source view contains all the source code for the stored procedures, functions, and triggers in the current user's schema. By specifying the name of the procedure in the WHERE clause, the query filters the result set to only show the source code for the SALARY_CALC procedure.

Option B is incorrect. There is no column named "source_name" in the user_source view. Therefore, this query will return an error.

Option C is incorrect. The user_objects view contains information about all objects in the current user's schema, including tables, views, indexes, and procedures. However, the view does not contain the source code for the procedures. Therefore, this query will not return any rows.

Option D is incorrect. The condition "AND owner='JOHN'" is unnecessary because the user_source view only contains source code for the objects owned by the current user. Therefore, this query will return the same result as option A, but with an unnecessary condition.

The Answer is: A. SELECT text FROM user_source WHERE name ='SALARY_CALC';

Multiple choice technology databases
  1. unique

  2. not null

  3. check

  4. primary key

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

The NOT NULL constraint can only be defined at the column level because it restricts individual column values. Constraints like UNIQUE, CHECK, and PRIMARY KEY can be defined at either column or table level, but NOT NULL is inherently column-specific.

Multiple choice technology databases
  1. &

  2. accept

  3. prompt

  4. &&

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

In SQL*Plus, a single ampersand & prompts the user for a value every time it is encountered. The double ampersand && defines a substitution variable that prompts the user only once and reuses that value throughout the session without prompting again.

Multiple choice technology databases
  1. Create and drop a materialized view

  2. Grant and revoke the role to and from other users

  3. Enable the role and exercise any privileges in the role's privilege domain

  4. Select from a table

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

The user SH has been granted privileges to create/drop materialized views and dimensions, and can grant/revoke the dw_manager role with ADMIN OPTION. However, SH has not been granted SELECT privileges on any tables, so cannot select from tables (option D is correct - SH cannot perform this action).