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 databases
  1. Using Rollup() function

  2. Using SUBTOT() function

  3. Using SUBSUM() function

  4. All the above

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

The Rollup function is the standard method for calculating subtotals and aggregated values in data analysis tools, databases (especially MongoDB with $rollup), and spreadsheet applications. While other functions like SUBTOTAL exist, Rollup is the most widely applicable approach for hierarchical aggregation. Option D cannot be correct since SUBTOT and SUBSUM are not standard function names.

Multiple choice technology web technology
  1. Create Read Update Delete

  2. Create Request Update Delete

  3. Create Read Update Drop

  4. Create Redo Update Direct

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

CRUD represents the four basic operations of persistent storage: Create (insert new records), Read (retrieve existing data), Update (modify existing records), and Delete (remove records). This pattern is fundamental in database management and web application development.

Multiple choice technology security
  1. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(validatedUserId);

  2. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL(validatedUserId);

  3. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL( new Codec(), validatedUserId);

  4. None of the above

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

Oracle databases have specific SQL syntax requirements, so encodeForOraSQL is the correct encoder that handles Oracle-specific escaping (like handling quotes, special characters in Oracle SQL). Generic encodeForSQL might not account for Oracle's unique syntax. Option C is incorrect because ValidationUtil methods are static and don't require a Codec object parameter.

Multiple choice technology security
  1. Use the com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(String input) method

  2. Use PreparedStatement constructs and use the setXXX methods on the PreparedStatement object

  3. Use the Java createStatement construct to execute the query

  4. Concatenate your SQL string together using dynamic input and create and execute a PreparedStatement object using that query

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

PreparedStatement with setXXX methods is the strongest defense because it separates SQL logic from data, treating user input as parameters rather than concatenating it into the query string. This completely eliminates SQL injection at the database driver level. Encoding methods (option A) are fragile workarounds - if you forget to encode even once, you're vulnerable. createStatement with concatenated strings (option C/D) is exactly what causes SQL injection vulnerabilities.

Multiple choice technology databases
  1. INSERT INTO r4r_team (id, username, exp) VALUES (1, ‘r4r01’, ‘2’);

  2. INSERT INTO r4r_team VALUES (1, ‘r4r01’, ‘2’);

  3. INSERT INTO r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

  4. INSERT INTO table r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

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

Both A and B are correct INSERT syntax. A explicitly specifies column names (recommended), while B omits them (requires VALUES match table column order exactly). C and D are incorrect - 'VALUE' is not valid SQL (must be VALUES), and 'INSERT INTO table' syntax is wrong.

Multiple choice technology databases
  1. Used to select username,exp, salary from r4r_team which is decreasing order by username.

  2. Used to select username,exp, salary from r4r_team which is increasing order by username.

  3. Used to select username,exp, salary from r4r_team which is decreasing order by exp.

  4. none

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

ORDER BY username DESC sorts in decreasing (descending) order by username, not increasing order and not by the exp column. DESC = highest to lowest, DESC only applies to username, not to exp.

Multiple choice technology databases
  1. These are Operators .Which are used to filter records based on more than one conditions.

  2. These Operators are used to join two tables.

  3. Never used in SQL

  4. None

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

In SQL, AND and OR are logical operators used in the WHERE clause to filter records by combining multiple conditions. They do not join tables (which is done via JOIN operations) and are widely used in database querying, making the first option correct.

Multiple choice technology databases
  1. BETWEEN -->>Used for range with in values

  2. LIKE -->>Used for Search a pattern

  3. IN -->>return east one of the columns in given set of values

  4. None

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

BETWEEN filters rows within a range (inclusive). LIKE searches for patterns using wildcards (% and _). IN checks if a value equals at least one value in a set (not 'east' - likely a typo for 'at least' or 'exists'). D is false.

Multiple choice technology databases
  1. true.

  2. false.

  3. both are not used into SQL.

  4. Both are used assembly languages only.

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

In SQL, both <> and != are standard inequality operators - they are functionally identical. Both are valid in SQL (not assembly only), and both serve the same 'not equal' purpose.