![]() ![]() ![]() In this instance the constraints must be removed before the TRUNCATE can be executed, before being reinstated once finished. The second tab shows performing the same function but with a MySQL database. In the following examples, the first tab shows how to perform a TRUNCATE on a Postgres database by using a $queryRaw look up that maps over the table and TRUNCATES all tables in a single query. If you are comfortable working with raw SQL you can perform a TRUNCATE on a table by utilizing $executeRawUnsafe. Deleting all data with raw SQL / TRUNCATE Note: The $transaction performs a cascading delete on each models table so they have to be called in order. Note that this scaling issue does not apply when using the MongoDB connector. When working with relational databases, this function doesn't scale as well as having a more generic solution which looks up and TRUNCATEs your tables regardless of their relational constraints.Works well when you know the structure of your schema ahead of time. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |