Finding orphaned files


SQL query which returns you a list of files which aren't assigned to any node. Use with care! Source:

Get raw version
  1. SELECT fm.*
  2. FROM file_managed AS fm
  3. LEFT OUTER JOIN file_usage AS fu ON ( fm.fid = fu.fid )
  4. LEFT OUTER JOIN node AS n ON ( = n.nid )
  5. WHERE (fu.TYPE = 'node' OR fu.TYPE IS NULL) AND n.nid IS NULL