Export data from the DB2 database using a shell script based on the user name, database name, and password entered
(1) The a.sh script is as follows
#!/usr/bin/"" "" " "" EXPORT To/home/practice/data/a.del of del select * from a "
(2) Connect to Linux and execute with the following command
Su-db2inst1-c "/home/practice/a.sh"
The above code is the key, where the a.sh file is stored under the/home/practice path
[Email protected] practice]#chmod+x A.SH[email protected] data]#su-Db2inst1-c"/home/practice/a.sh"Please input your dbname:oliverdbplease input your username:db2inst1please input your password:db2inst1 Database Connection Information Database Server= db2/linuxx866410.5.5SQL Authorization ID=db2inst1 Local Database alias=oliverdbsql3104n The Export utility is beginning to export data tofile "/home/practice/data/a.del". sql3105n The Export utility has finished exporting"2"rows. Number of rows exported:2
So far, the data has been exported from the database Oiliverdb to the directory/home/practice/data.
Using the shell to export data from a DB2 database