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]'
3
  • 2
    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>" Commented Mar 28, 2011 at 16:06
  • thank you that. Now I know everything I needed to know to finish my script :-)
    – Radek
    Commented Mar 28, 2011 at 22:07
  • 4
    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;" Commented Oct 1, 2019 at 13:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.