Day 21
Quiz
1: | From which two sources can you generate SQL scripts? |
A1: | You can generate SQL scripts from database tables and the data dictionary. |
2: | Will the following SQL statement work? Will the generated output work?SQL> SET ECHO OFF SQL> SET FEEDBACK OFF SQL> SPOOL CNT.SQL SQL> SELECT 'COUNT(*) FROM ' || TABLE_NAME || ';' 2 FROM CAT 3 / |
A2: | Yes, the SQL statement will generate a SQL script, but the generated script will not work. You need SELECT 'SELECT' in front of COUNT(*):
SELECT 'SELECT COUNT(*) FROM ' || TABLE_NAME || ';' Otherwise, your output will look like COUNT(*) FROM TABLE_NAME; which is not a valid SQL statement. |
3: | Will the following SQL statement work? Will the generated output work?SQL> SET ECHO OFF SQL> SET FEEDBACK OFF ... |
Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.