40 likes | 209 Views
DB2. Connecting to DB2:. Connecting and keeping the shell prompt: Connecting and getting a db2 prompt: Executing a command from the command line after connecting Executing a file full of commands (separated by ;) . > db2 “connect to <database_name> user <userID> using <password>”. > db2
E N D
Connecting to DB2: • Connecting and keeping the shell prompt: • Connecting and getting a db2 prompt: • Executing a command from the command line after connecting • Executing a file full of commands (separated by ;) > db2 “connect to <database_name> user <userID> using <password>” > db2 db2 => connect to ... > db2 “select * from book” > db2 -tf query.sql
Connecting to DB2: • Executing a file full of commands (separated by @): • Suppress column headers and trailers of select statement. • Echo current command > db2 -td@ -f query.sql [pletcha@joyous temp]$ db2 -x "select * from book" 1-23 DB Ullman 01/01/1982 23.00 CSP 2-34 Netw T'baum 01/01/1981 37.00 PH 3-56 Queue K'rock 01/01/1978 25.00 Wiley 4-76 SysD J'son 01/01/1981 32.00 PH 1-52 DB Date 01/01/1984 28.00 AW 6-99 MMM Br'kes 01/01/1978 12.00 AW 7-45 Arch Baer 01/01/1981 35.00 CSP > db2 -v -tf query.sql
Connecting to DB2: • Send all output to a file • Send output to file without headers and trailers • See other db2 command line options: > db2 “select * from book” -z outfile.db > db2 “select * from book” -vz outfile.db > db2 ? options