Summary: Remove all data from an external SQL database table. This is a fast, unfiltered delete of all rows.
URI Format
pfx-sql:truncate?table=myTable&dataSource=myDb
Parameters
|
Parameter |
Type |
Default |
Required |
Description |
|---|---|---|---|---|
|
|
String |
|
No |
Name of the Spring DataSource bean |
|
|
String |
|
Yes |
Target database table to truncate |
|
|
SQLDialect |
|
No |
SQL dialect |
Examples
Basic Truncate
<to uri="pfx-sql:truncate?table=staging_products&dataSource=myDb"/>
Truncate Before Full Load
<route id="fullLoad">
<from uri="timer://fullSync?repeatCount=1"/>
<!-- Clear staging table -->
<to uri="pfx-sql:truncate?table=staging_products&dataSource=myDb"/>
<!-- Fetch and load fresh data -->
<to uri="pfx-api:fetch?objectType=P&filter=allProducts"/>
<to uri="pfx-sql:insert?table=staging_products&mapper=stagingMapper&dataSource=myDb"/>
</route>
Truncate with PostgreSQL
<route id="truncatePostgres">
<from uri="timer://cleanup?repeatCount=1"/>
<to uri="pfx-sql:truncate?table=temp_data&dataSource=pgDb&dialect=POSTGRESQL"/>
</route>
Common Pitfalls
|
Problem |
Cause |
Fix |
|---|---|---|
|
Accidentally deleted all data |
Truncate removes all rows with no filter |
Use |
|
Foreign key constraint error |
Table has foreign key references from other tables |
Truncate dependent tables first, or use |
|
Missing |
Required parameter not provided |
Add |
See Also
-
pfx-sql Component — Parent reference
-
pfx-sql:delete — Delete specific rows using a filter