SQL query to bulk change short code in all posts

As Birgire mentioned in the comments, you can hook into the gallery output rather than performing a search/replace on the database.

From the WordPress Codex: Function Reference/shortcode atts gallery

Provides the ability to filter the array returned from shortcode_atts().

You want something like this:

add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_exclude_thumbnail', 10, 3 );
function gallery_shortcode_exclude_thumbnail( $result, $defaults, $atts ) {
    if ( empty( $atts['link'] ) ) {
        $result['link'] = 'file';
    }
    return $result;
}

Note: you may want to remove or change the condition empty check, depending on your needs.