db2中的schema如何重命名?

2025-03-12 18:36:24
推荐回答(1个)
回答1:

重命名schema ,相当于要重建schema,然后做表迁移。

具体步骤:参考下面的link

网页链接

1) Issue "db2look -d -e -o "

2) In the outputfile.sql file, find and change the schema to your new schema name. You can use UNIX text editor Vi and edit the file by use the following command ":1,$s///g" to search and replace or use any text editor that you desire.

3) Issue "db2move export". This will create several files, including a db2move.lst file, in your current directory.


4) You will also need to edit the generated db2move.lst file and change the schema names to the new desired name.

5) Drop existing user tables (this step is for renaming the schema within the same database)

6) Issue "db2 -tvf outputfile.sql" (this runs the output file generated by the db2look command to recreate the tables with the new schema name)

7) Issue "db2move import" (to import the data into the tables.)