1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
1
You can do this as a two step process.
- Dynamically building the SQL for getting the counts using the below query.
- Running the output of the SQL to generate the counts
with tname_vw(i) as (
SELECT concat(
'select ''',
table_name,
''' as table_name, count(*) from ',
table_name
)
FROM information_schema.tables
WHERE table_schema = 'schema_name'
)
select array_join(array_agg(i), ' union ') as result
from tname_vw
con risposta un anno fa
Contenuto pertinente
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 3 anni fa
- AWS UFFICIALEAggiornata 8 mesi fa
- AWS UFFICIALEAggiornata 2 anni fa
Thanks MKB,
this query returns one row with the following string:
""" select table_1 as table_name, count() from table_1 union select table_2 as table_name, count() from table_2 ... """
AWS-learner, Once you run the Query within the sting, you should be seeing the counts for the respective tables in the schema. Does that address your issue?