This set of PL/SQL Multiple Choice Questions & Answers (MCQs) focuses on “PL/SQL Syntax”.
1. Which of the following syntax is correct way to declare a variable in PL/SQL?
a) datatype variable_name [NOT NULL := value ];
b) variable_name datatype [NOT NULL := value ];
c) variable_name datatype;
d) variable_name datatype (NOT NULL := value );
View Answer
Explanation: The correct way to declare a variable in PL/SQL is – variable_name
datatype [NOT NULL := VALUE];
Datatype is written after the variable name and the NOT NULL constraint and the value is optional in the declaration part of the variable.
2. Which of the following statement is used to initialise a variable in PL/SQL?
a) variable_name datatype := value;
b) datatype variable_name := value;
c) variable_name datatype = value;
d) datatype variable_name = value;
View Answer
Explanation: The statement which is used to initialise a variable in PL/SQL is –
variable_name datatype := VALUE;
The datatype is after the variable name and the value is assigned using := (assignment operator).
3. Which of the following statement is used to take input from the user in PL/SQL?
a) variable_name datatype = &variable_name;
b) datatype variable_name := &variable_name;
c) datatype variable_name = &variable_name;
d) variable_name datatype := &variable_name;
View Answer
Explanation: The statement which is used to take input from the user in PL/SQL is –
variable_name datatype := &variable_name;
The assignment operator (:=) is followed by &variable_name to take input from the user.
4. What will be the output of the following PL/SQL code?
SQL> SET SERVEROUTPUT ON; SQL> DECLARE a varchar2(20) := 'Sanfoundry' ; BEGIN dbms_output.put_line(a); END; /
a)
Sanfoundry procedure successfully completed.
b)
PL/SQL procedure successfully completed.
c)
Sanfoundry PL/SQL procedure successfully completed.
d)
SanfoundryView Answer
Explanation: The output of the following code is –
Sanfoundry PL/SQL PROCEDURE successfully completed.
The statement PL/SQL procedure successfully completed is always printed after a successful compilation and execution of a PL/SQL code.
5. The slash (/) tells the SQL*Plus to execute the block written.
a) True
b) False
View Answer
Explanation: The slash (/) at the end of any Pl/SQL code block tells the SQL*Plus to execute the written block. SQL Plus is a Oracle Database utility, with a basic command-line interface, commonly used by users and administrators to administer a database.
Sanfoundry Global Education & Learning Series – PL/SQL.
To practice all areas of PL/SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]