Database-MySQL [3i Infotech Placement]: Sample Questions 136 - 137 of 162


Question 136


Write in Short

Short Answer▾

What is the output of the following query?

SELECT TRUNC (1234.5678, -2) FROM DUAL;


  • Output is ‘1200’ .
  • This negative number in truncate would remove the digits before decimal point and replace it.
  • If the negative parameter is passed under TRUNC function truncation will be done below decimal place i.e..
    • -1 means trunc to 10th (1234 becomes 1230)
    • -2 means trunc to 100th (1234 becomes 1200)
    • -3 means trunc to 1000th (1234 becomes 1000)

Question 137


Describe in Detail


Why would you set up indexes on database table?


  • Indexes are used to retrieve data from the database.
  • Users are just used to speed up searches/queries, they cannot see the index.
  • Indexes can create using one or more columns of a database table, providing the basis for both random lookups and efficient access of ordered records.
  • A database index allows a query to efficiently retrieve data from a database.
  • Indexes are related to specific tables and consist of one or more keys.
  • Create INDEX syntax:

CREATE INDEX index_name

ON table_name (column1, column2, … .) ;

Developed by: