Can't Delete Table in Retool DB

I am trying to delete some tables in Retool DB but it is not allowing me to. I keep getting a:
"Cannot drop table "MR_Equipment" because other objects depend on it"

But i am unsure what other objects depend on it.. Is it another Table another App? I have a few i want to delete but i am unable to do so. Some help would be appreciated.

Do you have a Foreign key relationship?

Hi @PadenM,

The error message you're receiving indicates that the MR_Equipment table is being referenced by other objects in your Retool database. This could be another table, a view, or even a trigger.

To identify which objects are depending on the MR_Equipment table, you can use the following SQL query:

  referenced_object_name = 'MR_Equipment';

This will return a list of all objects that are referencing the MR_Equipment table, along with their type.

Once you have identified the dependent objects, you can either drop them first, or use the CASCADE option to drop the MR_Equipment table along with its dependents.

To drop the dependent objects first:

  1. Drop each of the dependent objects, one by one.
  2. Once all of the dependent objects have been dropped, you will be able to drop the MR_Equipment table without any errors.

To drop the MR_Equipment table with the CASCADE option:

  1. Run the following SQL query:

This will drop the MR_Equipment table and all of its dependents.

I hope this helps!




Thats a great idea Patrick! So with retool how can i do that? i tried running that query in retool and it also connected it to azure data studio to see around and could get it to work.
i got the error: error: "relation "information_schema.dependents" does not exist"

@PadenM You should be able to check any foreign key dependents in the UI as well. Table columns that contain foreign keys from other tables are denoted with a :zap:.
Screenshot 2023-11-14 at 10.45.21 AM

Clicking on the column and selecting Settings will bring up the column information, which includes the referenced table.

You can then remove / alter these columns manually or run the CASCADE query that @PatrickMast shared above.

Ok i went to edit the primary key and it then showed the error of which other table it was referenced by. it was a sample one i used one a while ago and forgot about.. It was difficult to find with just looking at columns of other tables with quite a few of them to go through.

I appreciate all the help!

1 Like