Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
zagzebski
Contributor

Drop all tables at once or one at a time

It might not make a diiference but I was wondering if there was any efficienies with dropping all resident tables at end of script versus one at a time throughout the script.

1 Solution

Accepted Solutions
mov
Esteemed Contributor III

Re: Drop all tables at once or one at a time

I expect (maybe unreasonably) that dropping a table allows to free up some memory - hence always drop a table as soon as it's not needed anymore.

Regards,

Michael

10 Replies

Re: Drop all tables at once or one at a time

Hi,

To drop multiple tables

Drop Tables TableName1, TableName2....;

To drop single tables

Drop Table TableName;

Celambarasan

zagzebski
Contributor

Re: Drop all tables at once or one at a time

Celambarasan -

Sorry I didn't make myself clear. What I am wondering does it make a difference one way or aonther to drop all temporary tables at one time at end of script versus one at a time throughout the script?  Is either way more efficient?

mov
Esteemed Contributor III

Re: Drop all tables at once or one at a time

I expect (maybe unreasonably) that dropping a table allows to free up some memory - hence always drop a table as soon as it's not needed anymore.

Regards,

Michael

zagzebski
Contributor

Re: Drop all tables at once or one at a time

Thanks!

Re: Drop all tables at once or one at a time

Yes Michael is correct.

During the reload each and every table placed in memory(RAM) for faster access. If the data is huge then it slow downs further process.

It is a good practice to delete the tables often when the table is needed no more.

Celambarasan

MVP
MVP

Re: Drop all tables at once or one at a time

Btw. it also slows down with associations between tables on same column names. So, recommendation is always to drop temp tables at early stage (if not needed later).

- Ralf

preminqlik
Valued Contributor II

Re: Drop all tables at once or one at a time

first estimate the number of tables and use the following code ,

suppose my estimation is 250 tables so i wrote 250 in following code :

//code begins

for i = 0 to 250

          LET d = TableName(i);

          if isnull(d) then

                    i = 250

          end if

          if d <> null() then

         drop $(d);

          end if

next

Exit Script;

//code ends

(note: it works for less than or equal to 250 tables ..if you require more than that just replace the digit in code as per your requirement)

-Thanks

Premhas

m2r4miller
New Contributor III

Re: Drop all tables at once or one at a time

You don't have to estimate the number of tables if you use the NoOfTables() function:

//code begins

vTables = TableName(0);
FOR i = 1 to NoOfTables() - 1

     LET d = TableName(i);
     LET vTables = vTables & ', ' & d;
     TRACE $(vTables);
NEXT
DROP Tables $(vTables);

Exit Script;

//code ends

The TRACE statement isn't necessary, I used it to verify the string was building properly...

I'm not sure how many tables can be listed in one DROP Tables command, though...

-Mark

Not applicable

Re: Drop all tables at once or one at a time

Hi,

Try this script

Let vDropTables;

FOR i = 1 to NoOfTables()

    d=TableName(i);

    DROP Table $(i);

   NEXT i

Community Browser