Deleting cities

Hello everyone,

I need to delete all city records.

I know I can delete cities using the UI (Application config >> Organization >> Territories >> Cities), but that would take up a lot of time (since there are over 2m+ records).

Is there a faster and more convenient way to do that?

Hello,

You can to process by sql procedure directly in the database, even if it is more risky. The advantage in this case is that you can reuse the sql procedures afterwards.
DELETE FROM BASE_CITY AS c WHERE c.id NOT IN (SELECT DISTINCT a.city FROM BASE_ADDRESS AS a WHERE a.city IS NOT NULL) ;

Regards

1 J'aime