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 programming languages
  1. /* */


  2. rem

  3. None of the Above

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

SQL uses /* / for multi-line comments, similar to many C-style languages. Anything between / and / is treated as a comment and ignored by the SQL parser. The ** option is not valid SQL comment syntax, and 'rem' is used in some SQL dialects like SQL Server for single-line comments, but not for multi-line blocks.

Multiple choice technology programming languages
  1. Normalization

  2. Indexing

  3. Sequence

  4. Join

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

JOIN is the SQL mechanism for combining rows from two or more tables based on a related column between them. Normalization is about organizing tables to reduce redundancy, indexing improves query performance, and sequences generate unique numbers - none of these combine table data. JOINS (INNER, LEFT, RIGHT, FULL) are the fundamental SQL operation for merging data from multiple tables.

Multiple choice technology programming languages
  1. select empno, empname, salary from emp order by empname, salary desc;

  2. select empno from emp sort by empname, sal in desc;

  3. select empno, empname, salary from emp sort in empname, salary desc;

  4. select # from emp sort by empname and salary in desc;

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

The correct query is 'SELECT empno, empname, salary FROM emp ORDER BY empname, salary DESC'. This sorts by empname first (ascending by default), then by salary in descending order within each empname group. Options B and C incorrectly use 'SORT BY' instead of 'ORDER BY' (SQL uses ORDER BY). Option D has syntax errors with '#', 'sort by', and 'in desc' - the correct syntax is ORDER BY with DESC keyword.

Multiple choice technology programming languages
  1. GENERATE SEQUENCE SE START WITH 30 ADD BY 20;

  2. CREATE SEQUENCE SE START WITH 30 ADD BY 20;

  3. CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20;

  4. GENERATE SEQUENCE SE INITIATE WITH 30 INCREMENT BY 20;

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

The correct syntax is 'CREATE SEQUENCE SE START WITH 30 INCREMENT BY 20'. Options A and D incorrectly use 'GENERATE' instead of 'CREATE'. Option B uses 'ADD BY' which is not valid - the keyword is INCREMENT BY. Option C has the correct CREATE keyword, START WITH for initial value, and INCREMENT BY for the step value.

Multiple choice technology programming languages
  1. Table name can be an oracle reserved word

  2. Table names must begin with a letter

  3. Table names can contain in it numbers also

  4. None of the Above

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

When creating a table using CREATE TABLE in Oracle SQL, the table name cannot be a database reserved word (e.g., SELECT, TABLE). Table names must start with a letter and can contain numbers, making the reserved word restriction the only disallowed option listed.

Multiple choice technology programming languages
  1. Views are windows of existing table

  2. Creation of view is done by using CREATE VIEW statement

  3. Views do not contain data but table from which it is created contain data

  4. All the Above

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

All statements about Views are true. Views are virtual tables (windows) that don't store data themselves but display data from underlying tables. They are created using the CREATE VIEW statement. Views provide abstraction, security, and simplify complex queries. Option D ('All the Above') is correct because A, B, and C are all accurate statements about Views.

Multiple choice technology programming languages
  1. Non- procedural language

  2. Procedural language

  3. Database Language

  4. Both A. and C.

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

SQL is both non-procedural and a database language. Non-procedural means you specify WHAT data you want (declarative), not HOW to retrieve it (procedural). SQL is a domain-specific database language for relational databases. Option D is correct because it combines both characteristics - SQL's non-procedural nature and its role as a database language.

Multiple choice technology programming languages
  1. Sub queries must be enclosed in parenthesis

  2. BETWEEN cannot be used with a sub query

  3. Both A. and B.

  4. None of the Above

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

In SQL, subqueries must be enclosed in parentheses to define their scope within the main query. In addition, the BETWEEN operator cannot directly compare a value against a multi-row subquery without using operators like ANY or ALL. Therefore, both statements are true.

Multiple choice technology programming languages
  1. Structured database Language

  2. Structured programming Language

  3. Structured Query Analyzer

  4. Structured Query Language

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

SQL stands for Structured Query Language, used for retrieving (SELECT), updating (UPDATE, INSERT, DELETE), and defining (DDL) data in databases. Option A ('Structured database Language') and Option B ('Structured programming Language') are incorrect terms. Option C ('Structured Query Analyzer') is a tool, not the language. SQL is the standard database programming language for relational databases.

Multiple choice technology programming languages
  1. CHAR

  2. VARCHAR

  3. VARCHAR2

  4. All the Above

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

CHAR, VARCHAR, and VARCHAR2 are all character data types in SQL. CHAR is fixed-length, VARCHAR is variable-length (standard SQL), and VARCHAR2 is Oracle's proprietary variable-length type with additional features. All three store character/string data, making 'All the Above' the correct answer. These types are used for text data like names, addresses, and descriptions.

Multiple choice technology databases
  1. Set

  2. Multiset

  3. Volatile

  4. Temporary

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

A Multiset table in Teradata allows duplicate rows to be inserted, unlike a Set table which enforces uniqueness. Volatile and Temporary tables are table types related to scope/lifetime, not duplicate handling. The Multiset option is specifically designed to permit duplicate records.

Multiple choice technology databases
  1. True

  2. False

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

Teradata does have a ROWID pseudo-column that uniquely identifies each row in a table. This is accessible through the ROWID keyword in queries, similar to how other databases have row identifiers.