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

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

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 are used to quickly locate data without having to search every row in a database table every time a database table is accessed.
  • 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: