2
I need to delete to clean the database automatically in tables that are within different schemas, "public" and "cine";
I have the following query that returns me
SELECT concat('"',table_schema,'"', '.', '"',table_name, '"') as
table_name
FROM information_schema.columns
WHERE table_schema = 'public' OR table_schema = 'cine' AND
column_name = 'cine_uuid'
GROUP BY table_name, table_schema;
This, returns me all schemas and tables that have as column "cine_uuid". It is possible to delete as follows:
DELETE FROM [TABELAS] WHERE cine_uuid = '00000000-0000-0000-0000-000000000000'
What I intended was that from a query, to delete the various tables in the various schemas.
It is possible?
Claudio, there’s no way in one
QUERY
you delete the record from two Tables, you would need to delete the record one by one. The most you can do is if in one of the tables you could make oneDELETE CASCADE
, but then a table should have a relationship (FK
) with the other.– Richard Willian
I believe that you have how to do with plsql, I will try to do. When I needed it I did it in C#, easier for me, and it was using a truncate, so it doesn’t apply
– Rovann Linhalis