Showing posts with label Databases. Show all posts
Showing posts with label Databases. Show all posts

UpWork (oDesk) & Elance Oracle PL Test Question & Answers

15:28 Add Comment
UpWork (oDesk) & Elance Oracle PL Test Question & Answers are really very important to pass UpWork & Elance test. You will get top score at this skill test exam. If you found any problem or wrong answer please inform me via contact or comments. We will try to solve it in short. This test is extremely valuable to acquire knowledge of Oracle PL. Lets Start test.


Ques : The oracle server implicitly opens a cursor to process:
Ans  :  A Sql select statement
       DML Statements

Ques : Which two among the following programming constructs can be grouped within a package?
Ans  : Constant
       Sequence

Ques : Which two statements, among the following, describe the state of a package variable after executing the package in which it is declared?
Ans  : It persists across transactions within a session
       It persists from session to session for the same user

Ques : Which of the following is not a legal declaration?
Ans  : declare x,y varchar2(10);
      declare Sex boolean:=1;
 
Ques : Which two statements out of the following regarding packages are true?
Ans  : The package specification is required, but the package body is optional
       The specification and body of the package are stored separately in the database
 
Ques : A table has to be dropped from within a stored procedure. How can this be implemented
Ans  : Use the DBMS_DDL packaged routines in the procedure to drop the table

Ques : CREATE OR REPLACE PACKAGE manage_emp IS
tax_rate CONSTANT NUMBER(5,2) := .28;
v_id NUMBER;
PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER);
PROCEDURE delete_emp;
PROCEDURE update_emp;
FUNCTION cal_tax (p_sal NUMBER) RETURN NUMBER;
END manage_emp;
/
CREATE OR REPLACE PACKAGE BODY manage_emp IS

PROCEDURE update_sal (p_raise_amt NUMBER) IS
BEGIN
UPDATE emp SET sal = (sal * p_raise_emt) + sal
WHERE empno = v_id;
END;

PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER) IS
BEGIN
INSERT INTO emp(empno, deptno, sal) VALUES
(v_id, p_depntno, p_sal);
END insert_emp;

PROCEDURE delete_emp IS
BEGIN
DELETE FROM emp WHERE empno = v_id;
END delete_emp;

PROCEDURE update_emp IS
v_sal NUMBER(10,2);
v_raise NUMBER(10, 2);
BEGIN
SELECT sal INTO v_sal FROM emp WHERE empno = v_id;
IF v_sal < 500 THEN v_raise := .05;
ELSIP v_sal < 1000 THEN v_raise := .07;
ELSE v_raise := .04;
END IF;
update_sal(v_raise);
END update_emp;

FUNCTION cal_tax (p_sal NUMBER)RETURN NUMBER IS
BEGIN
RETURN p_sal * tax_rate;
END cal_tax;
END manage_emp;
/
What is the name of the private procedure in this package?
Ans  : UPDATE_SAL

Ques : An internal LOB is _____.
Ans  : Stored in the database

Ques : The technique employed by the Oracle engine to protect table data, when several people are accessing it is called:
Ans  :  Concurrency Control

Ques : Which table should be queried to determine when the procedure was last compiled?
Ans  : USER_OBJECTS

Ques : Which cursor dynamically allows passing values to a cursor while opening another cursor?
Ans  : Implicit Cursor

Ques : Which precomplied word is called, which when encountered, immediately binds the numbered exception handler to a name?
Ans  : Exception_init

Ques : How can migration be done from a LONG to a LOB data type for a column?
Ans  : Using ALTER TABLE statement

Ques : Which table and column can be queried to see all procedures and functions that have been marked invalid?
Ans  : USER_OBJECTS table,STATUS column

Ques : In which type of trigger can the OLD and NEW qualifiers can be used?
Ans  : Row level DML trigger

Ques : Examine the following trigger:

CREATE OR REPLACE TRIGGER Emp_count
AFTER DELETE ON Employee
FOR EACH ROW
DECLARE
n INTEGER;
BEGIN
SELECT COUNT(*) INTO n FROM employee;
DMBS_OUTPUT.PUT_LINE( 'There are now' || n || 'employees');
END;

This trigger results in an error after this SQL statement is entered: DELETE FROM Employee WHERE Empno = 7499;
How should the error be corrected?
Ans  : Take out the COUNT function because it is not allowed in a trigger

Ques : Which Section deals with handling of errors that arise during execution of the data manipulation statements, which makeup the PL/SQL Block?
Ans  : Exception

Ques :  Which of the following statements is true?
Ans  :  Stored functions can increase the efficiency of queries by performing functions in the query rather than in the application

Ques :Examine the following code:
CREATE OR REPLACE FUNCTION gen_email (first_name VARCHAR2, last_name VARCHAR2,
id NUMBER)
RETURN VARCHAR2 IS
email_name VARCHAR2(19);
BEGIN
email_name := SUBSTR(first_name, 1, 1) ||
SUBSTR(last_name, 1, 7) ||.@Oracle.com .;
UPDATE employees SET email = email_name
WHERE employee_id = id;
RETURN email_name;
END;
Which of the following statements removes the function?
Ans  : DROP FUNCTION gen_email;

Ques : In Pl/Sql, if the where clause evaluates to a set of data, which lock is used?
Ans  :  Page Level lock

Ques : If user defined error condition exists,Which of the following statements made a call to that exception?
Ans  : Raise

Ques : Which of the following are identified by the "INSTEAD OF" clause in a trigger?
Ans  : The view associated with the trigger

Ques : What type of trigger is created on the EMP table that monitors every row that is changed, and places this information into the AUDIT_TABLE?
Ans  : FOR EACH ROW trigger on the EMP table

Ques : Which procedure is called after a row has been fetched to transfer the value, from the select list of the cursor into a local variable?
Ans  :  Row_value

Ques : What is the maximum number of handlers processed before the PL/SQL block is exited, when an exception occurs?
Ans  : Only one

Ques : When the procedure or function is invoked, the Oracle engine loads the compiled procedure or function in the memory area called:
Ans  : PGA

Ques : What happens during the execute phase with dynamic SQL for INSERT, UPDATE, and DELETE operations?
Ans  : The area of memory established to process the SQL statement is released

Ques : Examine the following package specification:
CREATE OR REPLACE PACKAGE combine_all
IS
v_string VARCHAR2(100);
PROCEDURE combine (p_num_val NUMBER);
PROCEDURE combine (p_date_val DATE);
PROCEDURE combine (p_char_val VARCHAR2, p_num_val NUMBER);
END combine_all;
/
Which overloaded COMBINE procedure declaration can be added to this package specification?
Ans  :  PROCEDURE combine;

Ques : Which part of a database trigger determines the number of times the trigger body executes?
Ans  : Trigger type

Ques : Which table should be queried to check the status of a function?
Ans  : USER_OBJECTS

Ques : Which of the following statements is true regarding stored procedures?
Ans  :  A stored procedure must have at least one executable statement in the procedure body

Ques : Examine the following code:
CREATE OR REPLACE TRIGGER secure_emp
BEFORE LOGON ON employees
BEGIN
IF (TO_CHAR(SYSDATE, 'DY') IN ('SAT', 'SUN')) OR
(TO_CHAR(SYSDATE, 'HH24:MI')
NOT BETWEEN '08:00' AND '18:00')
THEN RAISE_APPLICATION_ERROR (-20500, 'You may
insert into the EMPLOYEES table only during
business hours.');
END IF;
END;
/
What type of trigger is it?
Ans  : This is an invalid trigger

Ques : Which code is stored in the database when a procedure or function is created in SQL*PLUS?
Ans  : Only P-CODE

Ques : Evaluate the following PL/SQL block:
DECLARE
v_low   NUMBER:=2;
v_upp   NUMBER:=100;
v_count NUMBER:=1;
BEGIN
FOR i IN v_low..v_low LOOP
INSERT INTO test(results)
VALUES (v_count)
v_count:=v_count+1;
END LOOP;
END;
How many times will the executable statements inside the FOR LOOP execute?
Ans  : 1

Ques : What can be done with the DBMS_LOB package?
Ans  : Use the DBMS_LOB.FILEEXISTS function to find the location of a BFILE

Ques : Examine the following code:
CREATE OR REPLACE TRIGGER UPD_SALARY
FOR EACH ROW
BEGIN
UPDATE TEAM
SET SALARY=SALARY+:NEW.SALARY
WHERE ID=:NEW.TEAM_ID
END;
Which statement must be added to make this trigger executable after updating the SALARY column of the PLAYER table?
Ans  : AFTER UPDATE ON PLAYER

Ques : Examine the following code:

CREATE OR REPLACE PACKAGE comm_package IS
g_comm NUMBER := 10;
PROCEDURE reset_comm(p_comm IN NUMBER);
END comm_package;

User MILLER executes the following code at 9:01am:
EXECUTE comm_package.g_comm := 15

User Smith executes the following code at 9:05am:
EXECUTE comm_package.g_comm := 20

Which of the following statement is true?
Ans  :  g_comm has a value of 15 at 9:06am for Miller

Ques : The CHECK_SAL procedure calls the UPD_SAL procedure. Both procedures are INVALID.Which command can be issued to recompile both procedures?
Ans  : ALTER PROCEDURE CHECK_SAL compile

Ques : Examine the following procedure:
PROCEDURE emp_salary
(v_bonus  BOOLEAN,
V_raise BOOLEAN,
V_issue_check in out BOOEAN)
is
BEGIN
v_issue_check:=v_bonus or v_raise;
END;
If v_bonus=TRUE and v_raise=NULL,which value is assigned to v_issue_check?
Ans  : TRUE

Ques : Which package construct must be declared and defined within the packages body?
Ans  :  Private Procedure

Ques : What happens when rows are found using a FETCH statement?
Ans  : The current row values are loaded into variables

Ques : Evaluate the following PL/SQL block:
DECLARE
result BOOLEAN;
BEGIN
DELETE FROM EMPloyee
WHERE dept_id IN (10,40,50);
result:=SQL%ISOPEN;
COMMIT:
END;

What will be the value of RESULT if three rows are deleted?
Ans  : FALSE

Ques : Which two statements among the following, regarding oracle database 10g PL/SQL support for LOB migration, are true?
Ans  : Standard package functions accept LOBs as parameters

Ques : Which command is used to disable all triggers on the EMPLOYEES table?
Ans  : ALTER TABLE employees DISABLE ALL TRIGGERS;

Ques : SQL%ISOPEN always evaluates to false in case of a/an:
Ans  : Implicit Cursor

Ques : Which datatype does the cursor attribute '%ISOPEN' return?
Ans  : BOOLEAN

Ques : Which of the following is a benefit of using procedures and functions?
Ans  : Procedures and Function avoid reparsing for multiple users by exploiting shared SQL areas

Ques : All packages can be recompiled by using an Oracle utility called:
Ans  :  Dbms_utility

Ques : Which type of variable should be used to assign the value TRUE, FALSE?
Ans  : Scalar

Ques : Examine the following code:
CREATE OR REPLACE TRIGGER update_emp
AFTER UPDATE ON emp
BEGIN
INSERT INTO audit_table (who, dated) VALUES (USER, SYSDATE);
END;
/
An UPDATE command is issued in the EMP table that results in changing 10 rows
How many rows are inserted into the AUDIT_TABLE ?
Ans  : 1

Thanks for watching this test Question & Answers. Please don't forget to leave a comment about this post. You can also find some more effective test question & answers, information, techniques, technology news, tutorials, online earning information, recent news, results, job news, job exam results, admission details & another related services on the following sites below. Happy Working!
News For Todays ARSBD UpWorkElanceTests ARSBD-JOBS DesignerTab UpLance

UpWork (oDesk) And Elance MySQL Test Question And Answers

16:16 Add Comment

MySQL Test

MySQL Test Question & Answers from oEtab are really very effective for a new & most freelancers on UpWork (Formerly oDesk) & Elance to study about MySQL with our website www.oEtab.blogspot.com. You can also easily learn MySQL perfectly to apply your acquired skills at your another professional area even without freelancing marketplace. Actually our main aim is to tech you & develop your professional skills step by step to perform on any application software to earn money. Please Never try to Participate any kinds of skill test directly without doing perfect study. Because it is very bad idea to develop your professional skills at MySQL. If you are really searching to develope your professional skills so you have to study first correctly. After that you should take your skill test examination at any online exam center, freelancing marketplace or any educational & training institution. So, Lets start to study for developing our professional skills to develope our nation.

Ques : Which of the following are true in case of Indexes for MYISAM Tables?
Ans  :  Indexes can have NULL values + BLOB and TEXT columns can be indexed

Ques : Below is the table “messages,” please find proper query and result from the choices below.

Id   Name   Other_Columns
-------------------------
1    A       A_data_1
2    A       A_data_2
3    A       A_data_3
4    B       B_data_1
5    B       B_data_2
6    C       C_data_1
Ans  :   select * from messages group by name Result: 1 A A_data_1 4 B B_data_1 6 C C_data_1

Ques :  How can an user quickly rename a MySQL database for InnoDB?
Ans  :  By creating the new empty database, then rename each table using: RENAME TABLE db_old_name.table_name TO db_new_name.table_name

Ques : Is it possible to insert several rows into a table with a single INSERT statement?
Ans  : Yes

Ques : Consider the following tables:


books

------

bookid

bookname

authorid

subjectid

popularityrating (the popularity of the book on a scale of 1 to 10)

language (such as French, English, German etc)



Subjects

---------

subjectid

subject (such as History, Geography, Mathematics etc)



authors

--------

authorid

authorname

country


Which is the query to determine the Authors who have written at least 1 book with a popularity rating of less than 5?
Ans  : select authorname from authors where authorid in (select authorid from books where popularityrating<5 b="">

Ques : The Flush statement cannot be used for:
Ans  :  Closing open connections

Ques : Consider the query:


SELECT name

FROM Students

WHERE name LIKE '_a%';


Which names will be displayed?
Ans  : Names containing "a" as the second letter

Ques : Which of the following is the best MySQL data type for currency values?
Ans  : DECIMAL(19,4)

Ques : What are MySQL Spatial Data Types in the following list?
Ans  : GEOMETRY

Ques : Examine the two SQL statements given below:

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC

What is true about them?
Ans  : The two statements produce identical results

Ques : Which of the following will raise MySQL's version of an error?
Ans  : SIGNAL

Ques : Which query will return values containing strings "Pizza", "Burger", or "Hotdog" in the database?
Ans  :  SELECT * FROM fiberbox WHERE field LIKE '%Pizza%' OR field LIKE '%Burger%' OR field LIKE '%Hotdog%';

Ques : Which datatype is used to store binary data in MySQL?
Ans  : BLOB

Ques : Which of the following will reset the MySQL password for a particular user?
Ans  : None of the above.

Ques : Which of the following is the best way to modify a table to allow null values?
Ans  :  ALTER TABLE table_name MODIFY column_name varchar(255) null

Ques : Which of the following will dump the whole MySQL database to a file?
Ans  : None of the above.

Ques : Which of the following is an alternative to groupwise maximum ranking (ex. ROW_NUMBER() in MS SQL)?
Ans  : Using self-join

Ques : Consider the following tables:

Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)

Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)

Authors
--------
AuthorId
AuthorName
Country

Which query will determine how many books have a popularity rating of more than 7 on each subject?
Ans  : select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating > 7 group by subjects.subject

Ques : Which of the following statements are true about SQL injection attacks?
Ans  : Wrapping all variables containing user input by a call to mysql_real_escape_string() makes the code immune to SQL injections.

Ques : Which of the following is an alternative to Subquery Factoring (ex. the 'WITH' clause in MS SQL Server)?
Ans  : The 'INNER JOIN' clause

Ques : Suppose a table has the following records:

+--------------+-------------+----------------+
| Item         | Price       | Brand          |
+--------------+-------------+----------------+
| Watch        | 100         | abc            |
| Watch        | 200         | xyz            |
| Glasses      | 300         | bcd            |
| Watch        | 500         | def            |
| Glasses      | 600         | fgh            |
+--------------+-------------+----------------+

Which of the following will select the highest-priced record per item?
Ans  : select item, brand, price from items where max(price) order by item

Ques : Which of the following will restore a MySQL DB from a .dump file?
Ans  : mysql -u -p < db_backup.dump

Ques : Which of the following will show when a table in a MySQL database was last updated?
Ans  : Using the following query: SELECT UPDATE_TIME FROM information_schema.tables WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME = 'table_name'

Ques :  Which of the following results in 0 (false)?
Ans  : BINARY "EXPERTRATING" LIKE "Exp%"

Ques : Which of the following relational database management systems is simple to embed in a larger program?
Ans  : SQLite

Ques : What is true about the ENUM data type?
Ans  : An enum may contain number enclosed in quotes

Ques : What will happen if two tables in a database are named rating and RATING?
Ans  :  This depends on lower_case_table_names system variable

Ques : How can a InnoDB database be backed up without locking the tables?
Ans  :  mysqldump --single-transaction db_name

Ques : What does the term "overhead" mean in MySQL?
Ans  : Temporary diskspace that the database uses to run some of the queries

Ques : Consider the following select statement and its output:

SELECT * FROM table1 ORDER BY column1;


Column1

--------

1

2

2

2

2

2

3


Given the above output, which one of the following commands deletes 3 of the 5 rows where column1 equals 2?
Ans  : DELETE FROM table1 WHERE column1=2 LIMIT 3

Ques : Consider the following queries:

create table foo (id int primary key auto_increment, name int);
create table foo2 (id int auto_increment primary key, foo_id int references foo(id) on delete cascade);
Ans  : If a row with id = 2 in table foo is deleted, all rows with foo_id = 2 in table foo2 are deleted

Ques : What is NDB?
Ans  :  An in-memory storage engine offering high-availability and data-persistence features

Ques : Which of the following statements are true?
Ans  : Names of databases, tables and columns can be up to 64 characters in length

Ques : Which of the following statements is used to change the structure of a table once it has been created?
Ans  : ALTER TABLE

Ques : What does DETERMINISTIC mean in the creation of a function?
Ans  : The function always returns the same value for the same input

Ques : Which of the following statements grants permission to Peter with password Software?
Ans  :  GRANT ALL ON testdb.* TO peter IDENTIFIED by 'Software'

Ques : What will happen if you query the emp table as shown below:

select empno, DISTINCT ename, Salary from emp;
Ans  : No values will be displayed because the statement will return an error

Ques : Which of the following is the best way to disable caching for a query?
Ans  : Use the SQL_NO_CACHE option in the query.

Ques : What is the maximum size of a row in a MyISAM table?
Ans  : 65,534

Ques : Can you run multiple MySQL servers on a single machine?
Ans  : Yes

Ques : hich of the following formats does the date field accept by default?
Ans  :  YYYY-MM-DD

Ques : State whether true or false:


In the 'where clause' of a select statement, the AND operator displays a row if any of the conditions listed are true. The OR operator displays a row if all of the conditions listed are true.
Ans  : False

Ques : What is the name of the utility used to extract NDB configuration information?
Ans  :  ndb_config

Ques : Which one of the following must be specified in every DELETE statement?
Ans  : Table Name

Ques : Which of the following are not Numeric column types?
Ans  : LARGEINT

Ques : Which of the following statements is true regarding multi-table querying in MySQL?
Ans  :  JOIN queries are faster than WHERE queries.

Ques : What is wrong with the following statement?
create table foo (id int auto_increment, name int);
Ans  :  The id column cannot be auto incremented because it has not been defined as a primary key

Ques :  Consider the following table definition:
CREATE TABLE table1 (
        column1 INT,
        column2 INT,
        column3 INT,
        column4 INT
)

Which one of the following is the correct syntax for adding the column, "column2a" after column2, to the table shown above?
Ans  : ALTER TABLE table1 ADD column2a INT AFTER column2

Ques :  Examine the data in the employees table given below:


last_name    department_id     salary

ALLEN         10                        3000

MILLER        20                      1500

King           20                     2200

Davis          30                      5000


Which of the following Subqueries will execute well?
Ans  : SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);

Ques : What privilege do you need to create a function?
Ans  : CREATE ROUTINE

Ques : What is wrong with the following query:

select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Ans  : The sub query can return more than one row, so, '=' should be replaced with 'in'

Ques : Which of the following is a correct way to show the last queries executed on MySQL?
Ans  : First execute SET GLOBAL log_output = 'TABLE'; Then execute SET GLOBAL general_log = 'ON'; The last queries executed are saved in the table mysql.general_log

Ques : Choose the appropriate query for the Products table where data should be displayed primarily in ascending order of the ProductGroup column. Secondary sorting should be in descending order of the CurrentStock column.
Ans  : Select * from Products order by ProductGroup,CurrentStock DESC

Ques : What is the correct SQL syntax for returning all the columns from a table named "Persons" sorted REVERSE alphabetically by "FirstName"?
Ans  : SELECT * FROM Persons ORDER BY FirstName DESC

Ques : You want to display the titles of books that meet the following criteria:

1. Purchased before November 11, 2002
2. Price is less than $500 or greater than $900

You want to sort the result by the date of purchase, starting with the most recently bought book.
Which of the following statements should you use?
Ans  : SELECT book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < '2002-11-11' ORDER BY purchase_date DESC;

Ques : State whether true or false:
Transactions and commit/rollback are supported by MySQL using the MyISAM engine
Ans  :  False

Ques : Consider the following table structure of students:

rollno int

name varchar(20)

course varchar(20)


What will be the query to display the courses in which the number of students enrolled is more than 5?
Ans  : Select course from students group by course having count(*) > 5;

Ques : MySQL supports 5 different int types. Which one takes 3 bytes?
Ans  : MEDIUMINT

Ques : Which of the following is the correct way to determine duplicate values?
Ans  : SELECT column_duplicated, COUNT(*) amount FROM table_name GROUP BY column_duplicated HAVING amount > 1

Ques : Examine the query:-

         select (2/2/4) from tab1;

where tab1 is a table with one row. This would give a result of:
Ans  :  .25

Ques : Which of the following commands will list the tables of the current database?
Ans  : SHOW TABLES

Ques : Which of the following is not a MySQL statement?
Ans  : ENUMERATE

Ques : When running the following SELECT query:

SELECT ID FROM (
    SELECT ID, name FROM (
        SELECT *
             FROM employee
    )
);

The error message 'Every derived table must have its own alias' appears.
Which of the following is the best solution for this error?
Ans  : SELECT ID FROM ( SELECT ID, name FROM ( SELECT * FROM employee ) AS T ) AS T;

Ques : Which of the following is not a Table Storage specifier in MySQL?
Ans  : STACK

Ques : The REPLACE statement is:
Ans  : Like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted

Ques : If you try to perform an arithmetic operation on a column containing NULL values, the output will be:
Ans  : NULL

Ques : Which of the following is the best way to insert a row, and to update an existing row, using a MySQL query?
Ans  : Use INSERT ... ON DUPLICATE KEY UPDATE statement

Ques : How will you change "Hansen" into "Nilsen" in the LastName column in the Persons Table?
Ans  : UPDATE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'

Ques : Which one of the following correctly selects rows from the table myTable that have NULL in column column1?
Ans  : SELECT * FROM myTable WHERE column1 IS NULL

Ques :  Is the FROM clause necessary in every SELECT statement?

Ans  : No