Apex Trigger To Prevent Delete Records

Sample Code:

trigger AccountTrigger on Account (before delete, before update, before insert, after insert, after update) {
    
    if (trigger.isDelete) {
        for (Account acc : trigger.old) {
            acc.addError('You cannot delete account records');
        }
    }
}