MCQs – SQL Basics


Q) Wrong statement about ORDER BY keyword is

  1. Used to sort the result-set in ascending or descending order
  2. The ORDER BY keyword sorts the records in ascending order by default.
  3. To sort the records in ascending order, use the ASC keyword.
  4. To sort the records in descending order, use the DECENDING keyword.

Answer: 4
To sort the records in descending order DESC keyword is used.


Q) Correct syntax query syntax to drop a column from a table is

  1. DELETE COLUMN column_name;
  2. DROP COLUMN column_name;
  3. ALTER TABLE table_name DROP COLUMN column_name;
  4. None is correct.

Answer: 3
To drop a column from an existing table, first table should be altered using ALTER TABLE statement.


Q) If you want to allow age of a person > 18 in the column Age of table Person, then which constraint will be applied to AGE column.

  1. Default
  2. Check
  3. NOT NULL
  4. None

Answer: 2
CHECK constraint is used to limit the value range placed in a column


Q) In a table, a column contains duplicate value, if you want to list all different value only, then which SQL clause is used?

  1. SQL DISTINCT
  2. SQL UNIQUE
  3. SQL BETWEEN
  4. SQL Exists

Answer: 1
DISTINCT keyword is used to fetch different (unique) value. UNIQUE keyword is known as constraint that is applied to a table, e.g. if UNIQUE is applied to a column, that column will allow only unique records to store and will not accept duplicate record.


Q) To give a temporary name to a table, or a column in a table for more readability, what is used?

  1. SQL Wildcards
  2. SQL aliases
  3. SQL LIKES
  4. SQL Comments

Answer: 2


Related Posts