Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

DROP TABLES WITH A REGULAR EXPRESSION

Hi everyone,

Do you know if I can do something like this?

DROP TABLE table*;

If I had a lot of tables like 'table1', 'table2',....'table300' and I´d like to dropt it, could be an easy way to delete all the tables.

I know that I can make a For..Next to delete all the tables, but I dont know if I can use regular expressions.

Thanks a lot.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

The simple answer is no. Tables must be explicitly listed and there's no support for regular expressions.

But if your actual testing can be done with a wildmatch(), you could handle it by looping through all the tables, like so:

FOR i=nooftables()-1 TO 0 STEP -1
LET vTable=tablename(i);
IF wildmatch(vTable,'table*') THEN
DROP TABLE $(vTable);
END IF
NEXT

View solution in original post

4 Replies
Not applicable
Author

I know it's an irritating answer, but: why?

I mean, if you have numbered tables containing similar values, why you do not load them in a single, common table instead of loading them separatedly?

Probably I'm missing something.

Bye

Not applicable
Author

Hi chisea80,

My question is not about how to load tables with similar values.

My question is about if I can use a regular expression to delete some tables at the same time, this tables could be similar or not it doesn´t matter.

Thanks.

johnw
Champion III
Champion III

The simple answer is no. Tables must be explicitly listed and there's no support for regular expressions.

But if your actual testing can be done with a wildmatch(), you could handle it by looping through all the tables, like so:

FOR i=nooftables()-1 TO 0 STEP -1
LET vTable=tablename(i);
IF wildmatch(vTable,'table*') THEN
DROP TABLE $(vTable);
END IF
NEXT

Not applicable
Author

Ok, thanks a lot