Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
SatyaPaleti
Creator III
Creator III

How to find out filesize of a table from database?

Hi Everyone,

How to find out filesize of a table from database?

for example I am loading xyz table from database. I am giving following condition

let vsize = FileSize('"public"."xyz"');

vsize is showing always null value even this table have a data. is there any alternate function ?

 

Thanks,

Satya

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Filesize() is filesystem function used to check size of files on disk not database tables

 

If you need to check if a table exists or not you need to query the information schema tables of the database

https://docs.oracle.com/cd/E19078-01/mysql/mysql-refman-5.0/information-schema.html#tables-table

https://chartio.com/learn/databases/using-information-schema-views-to-check-to-see-if-table-exists-i...

 

Query  the information schema table to check if the concerned table exists

for example

Temp:

Select * from information_schema_table where schema =''abc' and  tablename='xyz';

then use this information to proceed with IF block

if NoOfRows('Temp')>0 THEN   <<--if noofrows('Temp') > 0  means the concerned table exists in database

something

Else

Something else

End IF

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
Or
MVP
MVP

FileSize is for checking the size of files. A database table is not a file...

Most database providers let you find out the size of a specific table (as it exists within the DB), e.g.

https://chartio.com/resources/tutorials/how-to-get-the-size-of-a-table-in-mysql/

https://ppolyzos.com/2016/11/22/get-size-of-tables-in-sql-server/

But this is not native to Qlik.

SatyaPaleti
Creator III
Creator III
Author

Hi,

Thank you so much for response. Here we want to see a particular table exists in the database or not?

Our requirement is, My application should continue execution even the table is not available in the database. It have run from next load statement.

So we were using following 

let vsize = FileSize('"public"."xyz"');

if isnull(vsize) =-1

LET vExistFile = 0;
else   
 LET vExistFile = 1;
endif;

if '$(ExistFile)' then

Load statement

endif

Load Statement

you can check below requirement

Solved: Re: How to ignore cannot open file error qliksense - Qlik Community - 1923296

could you please help how to resolve this?

Thanks,

Satya

 

vinieme12
Champion III
Champion III

Filesize() is filesystem function used to check size of files on disk not database tables

 

If you need to check if a table exists or not you need to query the information schema tables of the database

https://docs.oracle.com/cd/E19078-01/mysql/mysql-refman-5.0/information-schema.html#tables-table

https://chartio.com/learn/databases/using-information-schema-views-to-check-to-see-if-table-exists-i...

 

Query  the information schema table to check if the concerned table exists

for example

Temp:

Select * from information_schema_table where schema =''abc' and  tablename='xyz';

then use this information to proceed with IF block

if NoOfRows('Temp')>0 THEN   <<--if noofrows('Temp') > 0  means the concerned table exists in database

something

Else

Something else

End IF

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SatyaPaleti
Creator III
Creator III
Author

Hi @vinieme12 

Thank you so much. This is the result I am expecting