DB2 modify table field type

It is troublesome for DB2 database to modify the table field type, and it is not easy to search for several methods, so I chose the most dumb method, but the method is very easy to use.

It is to export the original table structure and table data, then delete the original table, recreate the new table, and import the data.

1. Connect to the database
db2 connect to library name user table name using password
2. Export table definition
db2look -d library name -i user name -w password -e -nofed -t table name -o table name.sql
3. Export table data
db2 "export to table name. del of del select * from table name"
4. Delete the table to be modified
db2 "drop table table name"
5. Modify the exported table definition, you can use ftp transfer tool, can also be used in CMD The ftp command connects to the database, takes the exported table definition file locally to modify, and then uploads it.
6. Execute the modified new table definition
db2 -tf table name.sql
7. Import the original data into the new table
db2 "import from table name. del of del connotcount 5000 insert into table name"

Guess you like

Origin blog.csdn.net/wzs535131/article/details/106040540