Hour 22, Advanced SQL Topics

Team-Fly    

 
Sams Teach Yourself SQL in 24 Hours, Third Edition
By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Appendix C.  Answers to Quizzes and Exercises


Hour 22, "Advanced SQL Topics"

Quiz Answers

1:

Can a trigger be altered ?

A1:

No, the trigger must be replaced or re-created.

2:

When a cursor is closed, can you reuse the name ?

A2:

This is implementation-specific. In some implementations, the closing of the cursor will allow you to reuse the name and even free the memory, whereas for other implementations you must use the DEALLOCATE statement before the name can be reused.

3:

What command is used to retrieve the results after a cursor has been opened?

A3:

The FETCH command.

4:

Are triggers executed before or after an INSERT, DELETE, or UPDATE?

A4:

Triggers can be executed before or after an INSERT, DELETE, or UPDATE. There are many different types of triggers that can be created.

Exercise Answers

1:

Enter the following code at the mysql> prompt to generate DESCRIBE TABLE statements for all tables in your MySQL database:

  SELECT CONCAT('DESCRIBE ',TABLE_NAME,';') FROM TABLES_PRIV;  
A1:
2:

Write a SELECT statement that generates the SQL code to count all rows in each of your tables. (Hint: it is similar to exercise #1.)

A2:
 SELECT CONCAT('SELECT COUNT(*) FROM ',TABLE_NAME,';') FROM TABLES_PRIV; 

Team-Fly    
Top
 


Sams Teach Yourself SQL in 24 Hours
Sams Teach Yourself SQL in 24 Hours (5th Edition) (Sams Teach Yourself -- Hours)
ISBN: 0672335417
EAN: 2147483647
Year: 2002
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net