Vous êtes sur la page 1sur 7

SQL EXERCISE

Practice and practice we can improve our skills.

1. What does SQL stand for? Structured Question Language Strong Question Language Structured Query Language Structured Queue Language 2. What does the SQL FROM clause do? Specifies a search condition. Specifies the tables to retrieve rows from. Specifies the columns we are retrieving Specifies the attributes to retrieve rows from. 3. Which of the following SQL clauses is used to enter data into a SQL table? INSERT INTO WRITE ENTER SELECT 4. Which 2 SQL keywords specify the sorting direction of the result set retrieved with ORDER BY clause. ASC and DESC HIGH and LOW UP and DOWN Top and Bottom 5. We refer to a join as a self-join when we are using left and right join together We are joining two tables only we are joining more than 2 tables we are joining table to itself

6. RDBMS stands for Real Database Management System Relational Database Management System Read Database Master System Realtime Database Management System 7. The table rows are also known as Attributes Fields Records Entity 8. If you join a table to itself, what kind of join are you using? Selective Join. Natural Joun You can't join a table to itself. Self Join 9. The UPDATE SQL clause can update only one row at a time. update more than one row at a time. delete more than one row at a time. delete only one row at a time. 10. Which SQL statement selects all rows from table called Contest, with column ContestDate having values greater or equal to May 25, 20006? SELECT * FROM Contest HAVING ContestDate >= '05/25/2006' SELECT * FROM Contest WHERE ContestDate < '05/25/2006' SELECT * FROM Contest GROUPBY ContestDate >= '05/25/2006' SELECT * FROM Contest WHERE ContestDate >= '05/25/2006' 11. Which SQL keyword is used to retrieve a minimum value? DOWN LOW MIN LOWER

12. The INNER JOIN clause returns all rows that have matching value in the field on which the 2 tables are joined. returns only the rows from the first table, which have non-matching values with the second table in the field on which the 2 tables are joined. returns all rows from 2 tables. returns all the matching rows from 2 tables. 13. Which SQL keyword is used to retrieve only unique values? DISTINCTIVE DIFFERENT DISTINCT UNIQUE 14. If you don't specify ASC or DESC after a SQL ORDER BY clause, the following is used by default: There is no default value. DESC ASC Random 15. What is an index? An index is a database table attribute, which speeds-up data search within a table. An index is the same as alias. An index is a special way to join 2 or more tables. An index is a database row attribute, which speeds-up data search within a table. 16. What does ACID stand for? Access. Consistency. Isolation. Data. Access. Constraint. Index. Data. Access. Constant. Information. Data. Atomicity. Consistency. Isolation. Durability. 17. Which of the following SQL statements is correct? TRUNCATE Sales TABLE TRUNCATE * FROM TABLE Sales TRUNCATE TABLE Sales TRUNCATE * FROM COLUMN Sales

18. The IN SQL keyword Is used with the DISTINCT SQL keyword only. Is used with the INSERT SQL keyword only. Determines if a value matches any of the values in a list or a sub-query. Defines the tables we are selecting or deleting data from. 19. Sub-queries can be nested in UPDATE statements only. INSERT statements only. DELETE statements only. UPDATE, DELETE, INSERT and SELECT statements. 20. The LIKE SQL keyword is used along with.. WHERE clause. ORDER BY clause. JOIN clause. GROUP BY clause.

21 To remove duplicate rows from the result set of a select use the following keyword(s):

(1 point) NO DUPLICATES DISTINCT UNIQUE None of the above


22 A primary key may contain NULLS. (1 point)

True False
23 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? (1 point)

1 2 3 none of the above


24 SQL is a procedural language. (1 point)

True False
25 The only way to join two tables is by using standard, ANSI syntax. (1 point)

True False
26 What SQL clause is used to restrict the rows returned by a query? (1 point)

WHEN HAVING FROM WHERE


27 In a select with a group by clause, a where clause, and a having clause, the where

conditions are applied before the having conditions. (1 point) True False
28 Which SQL statement is used to add rows to a table? (1 point)

UPDATE INSERT ADD APPEND 29 Use the clause to restrict groups returned by a grouped query. (1 point) A) WHERE B) HAVING

C) DISTINCT D) DISTINCT ROW

30 The left outer join is one type of outer join. Another one is the . (1 point)

2 Marks Questions What is the difference between a "where" clause and a "having" clause? What is the basic form of a SQL statement to read data out of a table? What structure can you implement for the database to speed up table reads? What are the tradeoffs with having indexes? What is a "join"? What is "normalization"? "Denormalization"? Why do you sometimes want to denormalize? What is a "constraint"? What types of index data structures can you have? What is a "primary key What is a "functional dependency"? How does it relate to database table design? What is a "trigger"? Why can a "group by" or "order by" clause be expensive to process? What is "index covering" of a query? What is a SQL view?

40 Marks Question
1) Name and Explain different types of joins? Create two tables to demonstrate all types of

join OR Write the syntax for creating stored procedure, Function, Trigger and view. Give difference between stored procedure and function. Give at least one example for each.

Vous aimerez peut-être aussi