When a command is specified with ssh, the ssh won't allocate pseudo terminal (tty) for the session by default. As a consequence a different set of startup scripts is (might be) sourced. And/or different branches in the scripts are taken, based on absence/presence of TERM environment variable.
See ssh man:
When the user's identity has been accepted by the server, the server either executes the given command in a non-interactive session or, if no command has been specified, logs into the machine and gives the user a normal shell as an interactive session.
To force ssh to allocate tty nevertheless, use -t switch:
ssh -t [email protected] ‘./update_table.sh'
See ssh man:
-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
Though rather than working around the issue by forcing allocation of the pseudo terminal, you should better fix your startup scripts to set the same environment for all sessions.