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. SELECT COLUMNS(*) FROM Persons

  2. SELECT COUNT() FROM Persons

  3. SELECT COUNT(*) FROM Persons

  4. SELECT COLUMNS() FROM Persons

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

The standard SQL aggregate function to count rows is COUNT(). Standard SQL requires an expression or wildcard inside the parentheses, such as COUNT(*), to return the total number of records in the table, whereas empty parentheses are invalid syntax.

Multiple choice technology databases
  1. order

  2. sort

  3. order by

  4. sort by

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

The standard SQL syntax to sort the output of a query is ORDER BY, followed by the columns to sort. While ORDER is a component keyword and SORT exists in other paradigms, standard SQL uses the complete clause ORDER BY for sorting.

Multiple choice technology databases
  1. SELECT DIFFERENT

  2. SELECT DISTINCT

  3. SELECT UNIQUE

  4. SELECT PRIMARY

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

SQL uses the DISTINCT keyword to return only different (unique) values from a column, eliminating duplicates. The syntax is 'SELECT DISTINCT column_name FROM table_name'. Option A 'SELECT DIFFERENT' is invalid SQL. Option C 'SELECT UNIQUE' is not standard SQL (some databases support it but it's not the standard). Option D 'SELECT PRIMARY' is not a valid SQL clause for this purpose.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  2. SELECT * FROM Persons WHERE FirstName='a'

  3. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

  4. SELECT * FROM Persons WHERE FirstName='%a%'

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

SQL pattern matching uses the LIKE operator with wildcards. The '%' wildcard matches any sequence of characters. To match strings starting with 'a', use 'a%' where 'a' is the literal and '%' matches any following characters. Option A '%a' matches strings ending with 'a'. Option B uses exact equality instead of pattern matching. Option D '%a%' matches strings containing 'a' anywhere.

Multiple choice technology databases
  1. SELECT [all] FROM Persons

  2. SELECT Persons

  3. SELECT *.Persons

  4. SELECT * FROM Persons

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

To select all columns from a table in SQL, use the asterisk (*) wildcard with 'SELECT * FROM table_name'. Option A '[all]' is invalid SQL syntax. Option B 'SELECT Persons' would cause an error - it's interpreted as selecting a column named 'Persons', not the table. Option C 'SELECT *.Persons' is invalid syntax. Option D correctly uses the standard SQL wildcard syntax.

Multiple choice technology mainframe
  1. JOB

  2. DD

  3. EXEC

  4. All of the above

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

In Job Control Language (JCL), the NAME field (Jobname) is strictly mandatory on the JOB statement to identify the job to the operating system. Conversely, the EXEC and DD statements can use temporary, omitted, or blank positional name fields depending on placement.

Multiple choice technology databases
  1. iSQL*Plus commands manipulate table definitions in the database.

  2. iSQL*Plus is the Oracle proprietary interface for executing SQL statements.

  3. iSQL*Plus commands cannot be abbreviated.

  4. iSQL*Plus commands are accesses from a browser.

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

iSQL*Plus is Oracle's browser-based interface for executing SQL statements (B), accessed via web browser (D). Option A is false because iSQL*Plus commands don't directly manipulate table definitions - that's done with SQL DDL. Option C is false because iSQL*Plus commands CAN be abbreviated (like DESCRIBE to DESC). The key distinction is that iSQL*Plus is the environment/browser interface, while SQL commands interact with the database.

Multiple choice technology databases
  1. Use the DESCRIBE command in the EMP_DEPT VU view.

  2. Use the DEFINE VIEW command on the EMP_DEPT VU view.

  3. Query the USER_VIEWS data dictionary view to search for the EMP_DEPT_VU view.

  4. Query the USER_SOURCE data dictionary view to search for the EMP_DEPT_VU view.

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

To view a view's definition in Oracle, query USER_VIEWS data dictionary view, which stores the SELECT statement for each view. The TEXT column contains the view definition. DESCRIBE only shows column structure, not the SELECT statement. DEFINE VIEW is not a valid command. USER_SOURCE contains stored procedure/function code, not view definitions.

Multiple choice technology databases
  1. insert

  2. update

  3. select

  4. describe

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

DESCRIBE is an SQL*Plus command that displays column structure of database objects. INSERT, UPDATE, SELECT are SQL commands (DML/DDL), not SQL*Plus commands. SQL*Plus commands are environment commands like DESCRIBE, SET, SHOW, ACCEPT that control the SQL*Plus session, not data manipulation.

Multiple choice technology databases
  1. Selection, projection, join

  2. Difference, projection, join

  3. Selection, intersection, join

  4. Intersection, projection, join

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

This SQL performs selection (WHERE clause filters rows), projection (SELECT clause picks specific columns), and join (WHERE clause connects EMP and DEPARTMENT tables). Intersection and Difference are set operations not shown here. The query filters employees, projects only needed columns, and joins related tables.

Multiple choice technology programming languages
  1. my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
  2. my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
  3. my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')"); $statement->execute;
  4. my $statement = $dbh->sql("INSERT INTO names VALUES ('John')"); $statement->execute;
Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The DBI module requires two steps: first prepare the SQL statement with $dbh->prepare(), which returns a statement handle, then execute it with $statement->execute. Options A, B, and D are incorrect because they use non-existent methods (execute, run, sql) directly on the database handle instead of the proper prepare-then-execute pattern.

Multiple choice technology
  1. Insert, Delete and Update

  2. Select, Insert, Delete

  3. Select, Update, Insert

  4. None of the above

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

iCommand queries in MII are used for data manipulation operations: Insert, Delete, and Update. Select operations are handled by different query types (Xacute, SQL, TAG). The answer correctly identifies iCommand's DML (Data Manipulation Language) purpose.

Multiple choice technology databases
  1. True

  2. False

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

ORDER BY must be the last clause in a SELECT query. It can only appear after SELECT, FROM, WHERE, GROUP BY, and HAVING clauses. This is because ORDER BY operates on the final result set after all filtering, joining, and aggregation has been performed.

Multiple choice technology databases
  1. 50

  2. 30

  3. 20

  4. 40

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

In Oracle database, the maximum length of a table name is 30 characters. This limit applies to traditional Oracle versions and is a fundamental constraint that database administrators must follow when naming tables. Options A (50), C (20), and D (40) are incorrect as they don't match Oracle's standard naming limitation.