Yes, there is a difference and it is possible for a plugin to know when it is deactivated or deleted.
For deactivation the plugin may register a deactivation callback using register_deactivation_hook()
.
For deletion the plugin may either register a deletion callback using register_uninstall_hook()
or include a uninstall.php
file in its base folder. There’s an important note on the function reference about using the file method,
This file will be called, if it exists, during the uninstallation
process bypassing the uninstall hook. The plugin, when using the
‘uninstall.php’ should always check for the ‘WP_UNINSTALL_PLUGIN’
constant, before executing.
Sidenote: What I’ve seen over the years is that most plugins don’t bother doing any cleanup when they are deactivated or deleted leaving behind for example a settings mess in the options
table or scheduled WP cron hooks. Some plugins do the cleanup without telling you about it while a few have explicit settings that lets the user decide should the plugin data or tables be removed or not.