Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: scripting

Re: scripting

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: Sat, 03 Apr 1999 23:25:47 GMT
Message-ID: <3710931b.3887678@netnews.worldnet.att.net>


On Fri, 02 Apr 1999 11:59:52 -0500, Richard Cuello <rc370_at_columbia.edu> wrote:

> Below is a script. Can someone explain to me what is going on.
>Especially the concatenation in select statement.

OK, sure. My comments are interspersed with the code.

>set echo off

turns command echoing off, so that if you execute this script from a file, you won't see the commands displayed on the screen as they execute. You may want to use set echo on if you are experiencing problems.

>set head off

This command prevents column headings from printing when you select data from a table.

>set feed off

Setting feedback off prevents the "7 rows selected" message from printing after a select statement is executed.

>set pagesize 10000

Pagesize has been set to 10000 in an apparent attempt to prevent any page titles from printing. I recommend using set pagesize 0 instead, but this is no big deal either way.

>set linesize 200

By default, lines longer than 80 characters will be wrapped on the display. This sets the linesize to 200 to prevent wrapping.

>spool example3.sql

Causes all further output to be written to a file named example3.sql in your current working directory. NOTE: If you are running on a Windows platform, your current working directory is likely C:\ORANT\BIN. So if you can't find your output, check there.

>SELECT 'SELECT '||''''|| 'The Number of Rows In '||table_name ||
> ' is '||''''|| ' || (COUNT(*)) '||
> 'FROM ' ||table_name||';'
>FROM sys.all_tables
>WHERE owner = 'CTA';

This statement will yield the following for each table owned by CTA to which you have been granted access.

SELECT 'The Number of Rows In TABLE_NAME_HERE is ' || count(*)
FROM TABLE_NAME_HERE So it appears as if this script is generating another script that will count all the rows in each table owned by CTA.

>spool off

Stops writing the output to the example3.sql file, and closes the file.

>spool example3 /* This is the LIST file for output later!!!!!! */
Starts spooling output to a file named example3.lst. The default extension is lst, or maybe it's lis.

>@example3

This executes the example3.sql file, which should contain a bunch of SELECT...count(*) commands.

>spool off

Closes the example3.lis file. You should now be able to edit that file and see a list of tables together with rowcounts.

Hope this helps. Email me if you have other questions.

regards,

Jonathan Received on Sat Apr 03 1999 - 17:25:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US