Redshift - is it possible to run query that select from external table - only if table exist
1
vote
1
answer
1399
views
what i am try to do is something like this:
select
case when (/* here should come sql statement that check if table exist */)
then
(select count(*) from my_external_table)
else
0
end
I know that theoretically i could use the SVV_ALL views , but it's sometimes it's cuasing the query to be slow ..
As an example for what i am looking for , this postgres query could be great for me , but Redshift do not support the
to_regclass
function:
select
case when exist(select * from (select to_regclass('my_table') as rg) where rg IS NOT NULL )
then
(select count(*) from my_table)
else
0
end
Asked by Eyal leshem
(145 rep)
Apr 27, 2022, 08:57 AM
Last activity: Aug 5, 2025, 10:04 PM
Last activity: Aug 5, 2025, 10:04 PM