What would be the best way to touch all records in an object so that a trigger runs on each record? Is dataloader the best way or can this be achieve by a SQOL query or trigger?
For any reasonable size value, you need to either use the Data Loader, or use Batch Apex. I personally have a Batch Apex class that I use for this purpose, which I can call execute anonymous like so:
new BatchRecordGenerator.FromQuery('SELECT Id FROM Lead'),
This will be a feature in my open-source library when it's available. In the meantime, you should be able to figure out a basic way of doing this using interfaces. It really depends on what you need. My version will probably be far more involved than a simple answer here would satisfy.
That said, using the Data Loader is often effective. You can install/deploy the triggers to take care of "future" records, then query the records you need to update, then perform the update. The trigger should be able to take care of records created/updated after the deployment, and your data loader query can update those records that were not yet affected by the trigger.
If you know the value is less than 10,000 rows, and you won't exceed CPU limits, then a simple execute anonymous script will work:
update [SELECT Id FROM Lead WHERE ...];
You should always consider using Batch Apex when possible, because you don't have to leave your Data Loader running the entire time while it's running.
I just used the Salesforce Inspector extension for Chrome. This will do the batching for you with configurable options.
I Exported data using a query (specific to an object), then imported data the same way. You can click a button to copy the exported data and then paste it into the import screen. (Choose to
Update the records!)
All you need to "touch" an object is the Id, so that's all I exported.