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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic table and column identifiers?

Re: Dynamic table and column identifiers?

From: Roger Stapley <rstapley_at_uk.oracle.com>
Date: Thu, 28 Oct 1999 23:54:11 +0100
Message-ID: <3818D413.596A629F@uk.oracle.com>


SPOOL countem.sql

SELECT DECODE(ROWNUM, 1, NULL, 'UNION ')||'SELECT '||''''||atab.table_name||''''||' table_name, COUNT(*) FROM '||atab.table_name
FROM all_tab_columns acol

        ,all_tables atab

WHERE   acol.column_name = '&owner'
AND     atab.table_name = acol.table_name
AND     atab.owner = '&owner'

SPOOL OFF @countem.sql

I haven't got time right not but you can use this example to help build your second answer...

dd wrote:
>
> I want to
>
> select count(*)
> from {all tables that have a column named my_special_column}
> where {the table's owner}=my_special_user
>
> Also, I would like to
>
> select {n first columns}
> from {all tables that have a column named my_special_column}
> where {the table's owner}=my_special_user
> and my_special_column='my_special_value'
>
> Can somebody please rewrite pseudo-parts into SQL or show me another way to
> achieve this?
>
> Regards Dag
>
> STARTADDRESSdpedeATonlineDOTnoENDADDRESS


Received on Thu Oct 28 1999 - 17:54:11 CDT

Original text of this message

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