Tuesday, October 12, 2010

Shell Script to load data from a TableA to TableB in mysql

Suppose you have to select custom fields in TableA and insert those fields into TableB in mysql, then the following shell script command would be appropriate.

mysql -u user -p -D database -e 'insert into TableB select id, addr from TableA;'

Insert above code in a file and save it as ".sh" file extension. Then run it as "./Test.sh".

NOTE :- Test.sh must be stored in the server that mysql db server is running.

No comments:

Post a Comment