Is there any way through SQL commands, to import files into a custom field? E.g. photos of contacts?
I would do one manually with the UI, then look at tables civicrm_file, civicrm_entity_file, and the custom table to see what it creates, then base it on that. The name of the custom table depends on what field group you've put the field in, but it starts with civicrm_value_XXX.
You might also want changelog records (civicrm_log) and would need to deal with the filename suffixes that it adds to make it harder to guess the filenames for url hacking. See Aidan's answer for an alternative using php that should handle all this for you.