External actionscript and Internal as3?

whats the difference having a actionscript 3.0 in a layer(internal)

and a as3 .as file(external) ?

I know that it is just a simple question but I don’t even know their differences.
Is there something that you can’t do inside a as3 file in a layer ?

I just wanna make sure, can I access database inside an as3 in a file ?

Anyways thank you guys.