1 Reply Latest reply: Apr 16, 2018 9:21 AM by Graziella Serafin RSS

    Drop all Tables except

    Christian Schmitz

      Hi,

       

      I am looking for a way to drop all existing tables in my datamodel, except some Tables which can be stated in the script.

       

      I have found in the Community two solutions, which I tried and it definitely does not work for me.

       

      (Drop Tables *;

      Drop All Tables Except)

       

      Anybody has a workable solution for this case?

       

      Thx a lot,

       

      Chris

        • Re: Drop all Tables except
          Graziella Serafin

          I Christian,

          What is your issue with drop table statement?

          I had a problem wit it too, but I resolved. My problem was that at the end of the script not all table were dropped.

          After tests and retest, I undertood that, during dropping, the 'TableNumber' of existing table change!! So, if for example the number of "TableX" at the beginning is 15, during dropping can change in 10, 5,0...and when the n of your FOR is 15, the function "tablename(15)" is null.

           

          Then I revolved using a different approach...not a cycle, but a long string.

           

          FOR i = 0 to NoOfTables()-1

            TableList:

            LOAD TableName($(i)) as Tablename AUTOGENERATE 1

            WHERE not WildMatch(TableName($(i)), 'TableA','TableB','TableC');

          NEXT i

           

          TableList1:

          load concat(Tablename, ',') as Tablename1

          resident TableList;

          let vdrop= peek('Tablename1');

           

          DROP Tables TableList,TableList1;

          DROP Tables $(vdrop);

           

          I hope this can help you.