0

Right now im accessing a SAMPLE db which is in remote server. I found that its default instance db2inst1 with database name "SAMPLE". Since everybody using the same database for all their purposes, i want to create a new DB for my application. i tried connecting to the server through telnet. Since there are lot of data in SAMPLE db, cloning or duplicating same would help me save time. Please can someone post some set of commands or steps to duplicate SAMPLE db through telnet and sqldeveloper. If not commands or steps for creating a new db also is fine.

FYI: DB2 version - v10.5.0.3

2 Answers 2

1

The SAMPLE database is usually created with the db2sampl command (documented here for DB2 LUW 10.5). You can tell db2sampl to create another SAMPLE database under a different name with the -name option (note: this command must typically be run by someone with SYSADM privilege in the instance, e.g. by the db2inst1 user). For example, on a Linux box:

someuser@myserver:~$ sudo su - db2inst1
[sudo] password for someuser:
db2inst1@myserver:~$ db2sampl -name SAMPLE2
0

If you want an exact copy, you may need to ask an administrator to do a BACKUP and RESTORE into a new copy (or do it yourself if you have high enough permissions). Otherwise, if you do not need all the data (or structure) and just want a database to play around with, use the CREATE DATABASE command (pending you have high enough permissions) otherwise ask an administrator to do it for you.

Do note, you cannot have more than one database with the same alias catalogued on the same server. (So while there could be two copies of SAMPLE, perhaps one remote and one local, they both cannot be named SAMPLE on that server.)

2
  • Offcourse im in a situation to ask none as i have administrator access. Also i convinced myself of creating a new database but want set of commands like creating new user, creating instance like db2inst2 etc... then create database and assign newly created user to it. could you provide commands for these steps?? Commented Oct 12, 2015 at 13:29
  • unlike other databases, DB2 LUW doesn't have the concept of creating users. As long as the users are in the right groups they can perform certain instance level functions. After that it depends on whether or not the ID from the OS or LDAP is explicitly assigned permissions, belongs to a role that has permissions, or belongs to an OS or LDAP group that is assigned permissions. Commented Oct 12, 2015 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.