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
  1. SELECT product_name, SUM(product_price) FROM product GROUP BY category where SUM(product_price) > 1500

  2. SELECT product_name, SUM(product_price) FROM product GROUP BY category HAVING SUM(product_price) > 1500

  3. SELECT product_name, product_price FROM product GROUP BY category HAVING SUM(product_price) > 1500

  4. SELECT product_name, SUM(product_price) FROM product GROUP BY category HAVING product_price > 1500

  5. None of the above

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

This is the correct query for the desired result.

Multiple choice
  1. SELECT student_id, first_name, last_name, subject FROM student WHERE subject != 'Chemistry'

  2. SELECT student_id, first_name, last_name, subject FROM student WHERE subject NOT IN ('Chemistry' )

  3. SELECT student_id, first_name, last_name, subject FROM student WHERE subject = 'Chemistry'

  4. Both (1) and (2)

  5. None of the above

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

Both will produce desired result.

Multiple choice
  1. SELECT student_id, first_name, last_name FROM student Where first_name IN ('Virat', 'Suresh')

  2. SELECT student_id, first_name, last_name FROM student Where first_name Like ('Virat', 'Suresh')

  3. SELECT student_id, first_name, last_name FROM student Where first_name IN ('Virat' and 'Suresh')

  4. SELECT student_id, first_name, last_name FROM student Where first_name EXISTS ('Virat', 'Suresh')

  5. None of the above

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

This is a correct query for the specified result.

Multiple choice
  1. Delete FROM product WHERE product_price =2000;

  2. Delete produce_name, Product_price FROM product WHERE product_price =2000;

  3. Delete Product_price FROM product WHERE product_price =2000;

  4. Delete FROM product WHERE product_price ==2000;

  5. None of the above

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

This is the correct syntax for the desired result.

Multiple choice
  1. SELECT * FROM product where price>1500 and price<2500

  2. SELECT * FROM product where price>=1500 and price<=2500

  3. SELECT * FROM product where price between 1500 and 2500

  4. Both (2) and (3)

  5. None of the above

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

Yes, both are applicable for the desired result.

Multiple choice
  1. SELECT * FROM student WHERE first_name LIKE ‘S%’

  2. SELECT * FROM student WHERE name LIKE ‘S%’

  3. SELECT * first_name FROM student WHERE first_name LIKE ‘S%’

  4. SELECT * FROM student WHERE first_name LIKE ‘S’

  5. None of the above

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

This is correct SQL query to get specified records.

Multiple choice
  1. SELECT * FROM product WHERE NOT product_price=2000

  2. SELECT * FROM product WHERE product_price!=2000

  3. SELECT * FROM product WHERE EXCEPT product_price=2000

  4. Both (1) and (2)

  5. (1), (2) and (3) all are true

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

Yes, both are the correct queries to fetch specified records.

Multiple choice
  1. SELECT * FROM student WHERE subject != ’physics’ and subject != ’maths’

  2. SELECT * FROM student WHERE subject != ’physics’, subject != ’maths’

  3. SELECT * FROM student WHERE subject NOT IN (’physics’, ’maths’)

  4. Both (1) and (3)

  5. None of the above

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

Both are the correct queries.

Multiple choice
  1. SELECT * FROM student WHERE subject=’Maths’ OR subject='Physics’ OR subject=’sport’

  2. SELECT * FROM student WHERE subject IN (’Maths’, ’Physics’, ’sport’)

  3. SELECT * FROM student WHERE subject=’Maths’, subject='Physics’, subject=’sport’

  4. Both (1) and (2)

  5. Both (2) and (3)

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

Both are applicable for the specific result.

Multiple choice
  1. Primary key and foreign key of a database are not the same.

  2. Structure of the database is not defined during the database construct.

  3. Users are not affected by changes to the structure of the database.

  4. Structure of the database can be altered by anyone.

  5. Changes made to the physical structure is affected to the logical structure of the database.

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

This is the correct meaning of the data independence property of the database, as users are not affected by changes made to the structure of the database.

Multiple choice
  1. The name should not contain more than 16 characters.

  2. The name must start with a letter.

  3. The name can contain letters, numbers and underscores.

  4. The name should not contain spaces.

  5. The table name may contain any special character other than underscore.

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

This is not the correct statement as no other special character other than underscore can be be used to name any table in a database.