Database-MySQL [3i Infotech Placement]: Sample Questions 65 - 66 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 65

Edit

Describe in Detail

Essay▾

What will be the output of the following query?

SELECT REPLACE (TRANSLATE (LTRIM (RTRIM ( ‘ATHEN!’ ‘’ ) , ‘’ ) , ‘AN’ ‘⚹⚹’ ) , ‘⚹’ ‘TROUBLE’ ) FROM DUAL.

Explanation

  • 1st step: rtrim ( ‘! ! athen! !’ , ‘!’ )
    • Output becomes “! ! athen”
  • 2nd step: ltrim ( ″ athen ′ , ′ an ′ , ′ ⚹⚹ ′ )
    • Output becomes ″ ⚹ the ⚹ ″
  • 3rd step: trancelate ( ‘athen’ , ‘an’ , ‘⚹⚹’ )
    • Output becomes “⚹ the ⚹”
  • 4th step: replace ( ‘⚹ the ⚹’ , ‘⚹’ , ‘trouble’ )
  • Finally the output is “TROUBLETHETROUBLE” .

Question 66

Edit

Describe in Detail

Essay▾

What is a “trigger” ?

Explanation

The Database Trigger
  • A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database.
  • The trigger is mostly used for maintaining the integrity of the information on the database.
  • For example, when a new record (representing a new worker) is added to the employees table, new records should also be created in the tables of the taxes, vacations and salaries.

Use of Triggers

  • Automatically generate derived column values
  • Prevent invalid transactions
  • Enforce complex security authorizations
  • Enforce referential integrity across nodes in a distributed database
  • Enforce complex business rules
  • Provide transparent event logging
  • Provide sophisticated auditing
  • Maintain synchronous table replicates
  • Gather statistics on table access

Developed by: