I think you confused all of us with the references to vi when you are not using vi at all.
Your sed command is doing a lot of unnecessary switching between single quotes and double quotes. You can get exactly the same results as the sed command above just using:
sed -e "8s/$table_name/$schema_name.$table_name/" input_file
With the values you're using in this example, no quotes are needed at all. But if $table_name or $schema_name could expand to strings containing whitespace characters or characters that could have special meaning to the shell if they aren't quoted, the double quotes protect you in that case. The key point is that the shell doesn't expand variables inside single quotes, so you have to use double quotes instead of single quotes if you want sed to see the table_name and schema_name variables expanded in your sed substitute command.