oDesk MySQL 5.0 Test Answers 2012 PDF and Word File


MySQL 5.0 Test Answers
oDesk MySQL 5.0 Test Answers for oDesk Web Developer Contractor

Question : An RDBMS performs the following steps:
1)It calculates the results of the group functions of each group
2)It groups those rows together based on the group by clause
3)It orders the groups based on the results of the group functions in the order by clause
4)It chooses and eliminates groups based on the having clause

5)It chooses rows based on the where clause
Arrange the above steps in the correct order of execution:
 5,2,1,4,3


1)  What does SQL stand for?
       c)   Structured Query Language

2) Which SQL statement is used to extract data from a database?
       d)   SELECT

3) Which SQL statement is used to update data in a database?
      a)  UPDATE

4) Which SQL statement is used to delete data from a database?
       b) DELETE

5) Which SQL statement is used to insert new data in a database?
       c)  INSERT

6) With SQL, how do you select a column named "FirstName" from a table named "Persons"?
       b)  SELECT FirstName FROM Persons

7) With SQL, how do you select all the columns from a table named "Persons"?
       d)  SELECT * FROM Persons

8) With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" is "Peter"?
eter'
       d)SELECT * FROM Persons WHERE FirstName='Peter'

9) With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"?
       d) SELECT * FROM Persons WHERE FirstName LIKE 'a%'

10) The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true
       a) True

11) With SQL, how do you select all the records from a table named "Persons" where the "FirstName" is "Peter" and the "LastName" is "Jackson"?
       b)   SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

12) With SQL, how do you select all the records from a table named "Persons" where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?
       b) SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

13) Which SQL statement is used to return only different values?
       d)  SELECT DISTINCT

14) Which SQL keyword is used to sort the result-set?
       c)  ORDER BY

15) With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?
       b) SELECT * FROM Persons ORDER BY FirstName DESC

16) With SQL, how can you insert a new record into the "Persons" table?
       a)  INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

17) With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?
       a)  INSERT INTO Persons (LastName) VALUES ('Olsen')

18) How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons table?
       b) UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

19) With SQL, how can you delete the records where the "FirstName" is "Peter" in the Persons Table?
       a)  DELETE FROM Persons WHERE FirstName = 'Peter'

20) With SQL, how can you return the number of records in the "Persons" table?
       b) SELECT COUNT(*) FROM Persons

21) Given an employees table as follows: empid name managerid a1 bob NULL b1 jim a1 B2 tom a1 What value will select count(*) from employees return?
       c) 3

22) The result of a SELECT statement can contain duplicate rows.
       a)  True

23) Sometimes the expression "select count(*)" will return fewer rows than the expression "select count(value)".
       b) False

24) What type of lock will deny users any access to a table?
       c) EXCLUSIVE

25) Which of the following is the correct SQL statement to use to remove rows from a table?
       c) DELETE

26) The only way to join two tables is by using standard, ANSI syntax.
       b) False

27) A NULL value is treated as a blank or 0.
       b) False

28) The left outer join is one type of outer join. Another one is the.
       e)all of the above

Question 1
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
 The second statement returns an error

Question 2
Which of the following is not a numeric group function?
 Highest

Question 3
Examine the data in the EMPLOYEES table given below:
ALLEN                10                     3000
MILLER               20                     1500
KING                 20                     2200
DAVIS                30                     5000
Which of the following Subqueries work?
 SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
 SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);

Question 4
Which of the following statements are true?
 With DDL you can create and remove tables, schemas, domains, indexes and views

Question 5
Which of the following clauses are not allowed in a single row sub-query?
 Order by

Question 6
What is the collection of information stored in a database at a particular moment called?
 Instance

Question 7
The overall logical structure of a database can be expressed graphically by:
 Entity-Relationship Diagram

Question 8
Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating       (the popularity of the book ON a scale of 1 TO 10)
Languag?               (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject    (such AS History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which German books(if any) are more popular than all the French?
 select bookname from books where language='German' and popularityrating> (select max(popularityrating) from books where language='French')

Question 9
Which statements are true for views?
 The definition of a view is stored in data dictionary
 Views provide a more secure way of retrieving data

Question 10
Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have written books on two or more subjects? 
 select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId having count(*)>1)

Question 11
What does the term DDL stand for?
 Data Definition Language

Question 12
The concept of data independence is similar to the concept of ________
 Abstract data type

Question 13
What are the programs that execute automatically whenever DML operations are performed on tablds called?
 Triggers

Question 14
What clause should be used to display the rows of a table in ascending order of a particular column?
 Order By

Question 15
What is the error in the following query if the Students table contains several records?
SELECT name FROM students WHERE name =
(SELECT name FROM students ORDER BY name);
 = should be replace by in operator
 An order by clause is not allowed in a subquery

Question 16
How can data be accessed by users who do not have direct access to the tables?
 By creating views

Question 17
Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating       (the popularity of the book ON a scale of 1 TO 10)
Languag?               (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject    (such AS History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have written at least 1 book with a popularity rating of less than 5? 
 select authorname from authors where authorid in (select authorid from books where popularityrating<5)

Question 19
A table Students has a column called name which stores the names of the students. What will be the correct query to display the names of the students in reverse order?
 Select name from students order by name desc;


Question 20

_________ is the operation that displays certain columns from the table.
 Selection

Question 21
There is a column c1 in the table t to which a primary key pk is to be added. What will be the correct syntax?
 Alter table t add primary key(c1);

Question 22
The primary key index does not allow ________ data in a field.
 Null
 Duplicate


Question 23
Which of the following are aggregate functions in SQL?
 Avg
 Sum




DOWNLOAD


Share on Google Plus

About Mohammed Rafiq

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

2 comments:

  1. Thanks for the update you have nicely covered this topic. keep it up

    PHP 5 developer

    ReplyDelete
  2. 100% correct answer on odesk test

    Knowledge of sql server 2008 skills
    .
    You can check out for
    mcpd,
    asp.net
    questions too

    ReplyDelete