internal format in glTexImage*()

I am not clear about the role of the internel format in glTexImage*(); The format and the data type specifies the array we feed the function. Does the internel format specify how the data are stored in the texure memory. If the format are specified to be GL_RGBA, and the internel format are specified to be GL_LUMINANCE. Will GL transform the RGBA values to luminance values? Thank you.

Yes it will.
From the man page :

If an application wants to store the texture at a certain
resolution or in a certain format, it can request the resolution
and format with internalFormat. The GL will choose an internal
representation that closely approximates that requested by internalFormat, but
it may not match exactly.