9

how can I run

  • sql command UPDATE CONTACT SET EMAIL_ADDRESS = '[email protected]'
  • via command line
  • for db2 database
  • on linux
  • from a shell script file?

1 Answer 1

15

You need to be logged into your linux machine with an id that has "db2profile" in it's .profile.

If you are not sure what I'm talking about, look at the .profile of the db2 instance owner (usually db2inst1 unless you changed it during the install). The simplest thing would probably be to log in as the db2 instance owner.

Once you are logged in, type "db2" at the command line. If "db2" is not found, then recheck the .profile stuff.

To execute your sql command type the following at the command line (substitute with the name of the database you want to connect to):

db2 connect to <database name>
db2 UPDATE CONTACT SET EMAIL_ADDRESS = '[email protected]'
Sign up to request clarification or add additional context in comments.

3 Comments

Yes. If you are doing that, then you probably want to connect to the database as a specific user. In that case use "db2 connect to <database name> user <user name> using <pwd>"
thank you that. Now I know everything I needed to know to finish my script :-)
is there a way to connect and execute a command in the same command? similar to this: "db2 connect to <database name>; SELECT * FROM table;"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.