Database-MySQL [PCS Infotech Placement]: Sample Questions 5 - 7 of 23

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 5

Edit

Write in Short

Short Answer▾

How to write single quote in SQL?

Explanation

  • A single quote contains actual data to be inserted.
  • Single quote with two quotes it not the double quote character but two single-quote characters.
  • The single quote character is reserved for inserting information into a database and if a single quote is contained in data, the command become corrupted.
  • So solve the problem, simply replace any single quote with two quotes.
  • Bellow sample command performs replacement automatically:
    • sContent = Replace (sContent, “′” , “′ ′” )
    • where sContent contains the data that needs single quotes replaced

Question 6

Question

MCQ▾

Can PL/SQL reserved words be used in SQL?

Choices

Choice (4)

a.

No

b.

Yes

c.

All of the above

d.

None of the above

Answer

b.

Explanation

  • Yes, PL/SQL reserved words can be used with quotation.
  • The $ RESERVED_WORDS data dictionary view provides additional information on each reserved word.
  • Words reserved by PL/SQL are classified as keywords or reserved words.
  • Never to be used as identifiers.
  • Keywords can be used as identifiers but not recommended.

Question 7

Edit

Describe in Detail

Essay▾

Which are the mandatory parts of PL/SQL procedure?

Explanation

  • The PL/SQL stored procedure is a PL/SQL block with performs one or more specific task.
  • The procedure contains a header and a body

Header

  • The section before IS keyword is called procedure header.
  • Elements of procedure՚s header are:
  • Schema:
    • Optional name of the schema to which the procedure belongs.
    • Default is the current user.
    • We can specify a different user- the current user must have privileges to create a procedure.
  • Name:
    • Convention dictates that procedure name starts with a verb.
  • Parameters:
    • Optional list of parameters.
    • PL/SQL function parameters have different modes- IN, OUT and IN OUT.
  • AUTHID:
    • Determines execution privileges- privileges of the procedure owner or the privileges of current user specified by CURRENT_USER.

Body

  • Similar syntax as an anonymous block- consist of the declaration, execution, and exception.
  • Declaration and exception sections are optional.
  • At least one executable statement must be in the execution section.
  • PL/SQL procedure can have a RETURN statement, which does not take any expression or constant.

Developed by: