How to change the file path and name in DB2

Source: Internet
Author: User
Tags db2 connect db2 connect to

How DB2 changes the file path and name I personally feel that it is a bit difficult to change the file name in DB2. Although there are not many steps, it may be caused by the method used to ORACLE. It is relatively simple to change the path of the data file in ORACLE at www.2cto.com. Especially after 12C, you can change the file path with the following simple command: alter database move datafile 4 TO '/data/orcl/user01.dbf' it is relatively simple to move the file before 12C: OFFLINE change related files -- alter database datafile 4 OFFLINE file location or name -- mv/data1/orcl/user01.dbf/data/orcl/user01.dbf update control file Pointer -- alter database rename datafile 4 to '/data/orcl/user01.dbf' ONLINE-alter database datafile 4 ONLINE in DB2 to move files or rename files need to be backed up, this is a little cool for slave L E. For the database engineers who transferred to DB2, it may not be suitable. Www.2cto.com follow these steps: Modify the file path of the tablespace TEST file and name it. [Yansp @ db2server ~] $ Db2 connect to testdb Database Connection Information Database server = DB2/LINUX 9.7.0 SQL authorization ID = YANSP Local database alias = TESTDB [yansp @ db2server ~] $ Db2 list tablespace containers for 7 Tablespace Containers for Tablespace 7 Container ID = 0 Name =/dbauto/manual/test1.dbf Type = File Container ID = 1 Name =/dbauto/manual/test2.dbf Type = File www.2cto.com table space TEST has two containers: test1.dbf and test2.dbf, next we will move it to the upper-level directory and modify the file name. [Yansp @ db2server ~] $ Db2 restore database testdb tablespace \ (test \) from '/tmp' taken at 20130219003935 redirectSQL1277W A redirected restore operation is being already med. table space configuration can now be viewed and table spaces that do not use automatic storage can have their containers reconfigured. DB20000I The restore database command completed successfully. [yansp @ db2server ~] $ Db2 "set tablespace containers for 7 using (file '/dbauto/test01.dbf' 2000, file'/dbauto/test02.dbf' 2000)" DB20000I The set tablespace containers command completed successfully. [yansp @ db2server ~] $ Db2 restore database testdb continueDB20000I The restore database command completed successfully. [yansp @ db2server ~] $ Db2 rollforward database testdb to end of logs and stop Rollforward Status Input database alias = testdb Number of nodes have returned status = 1 Node number = 0 Rollforward status = not pending Next log file to be read = Log files processed =-Last committed transaction = 1970-01-01-00.00.00.000000 UTC DB20000I The ROLLFORWARD command completed successfully. [yansp @ db2server ~] $ Db2 list tablespace containers for 7 SQL1024N A database connection does not exist. SQLSTATE = 08003 [yansp @ db2server ~] $ Db2 connect to testdb Database Connection Information Database server = DB2/LINUX 9.7.0 SQL authorization ID = YANSP Local database alias = TESTDB [yansp @ db2server ~] $ Db2 list tablespace containers for 7 Tablespace Containers for Tablespace 7 Container ID = 0 Name =/dbauto/test01.dbf Type = File Container ID = 1 Name =/dbauto/test02.dbf Type = File

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.