DB2 common operation and maintenance command

DB2 is IBM's relational database management system introduced. Mainly used in banks, hospitals and other large institutions. DB2 now mainly consists of the following three series: DB2 for Linux, UNIX and Windows (LUW).

DB2 Installation depends compat-libstdc ++ libraries under Linux, the library needs to be installed first before installing DB2. Attaching the library run db2setup start the graphical interface DB2 installation program after the completion of the installation:

DB2 creates during installation db2inst1, db2fenc1 and dasusr1 three users, this three users will be added to the system to become users of the system can also be created prior to installation:

After switching to the db2inst1 user installation, operation db2cc start the graphical control center (DB2 V10.1 release from the start no longer contains graphical control center, using a command line or provided in IBM Data Studio management tools);

DB2 installation under Windows:

Run the installation program setup.exe program to start the installation, the installation process creates db2admin user and add this user to the Administrators group

After installation is complete db2cc launch control center:

DB2 service names and the port can be viewed using the following method:

Linux:

/ Etc / services file

Windows:

C: \ Windows \ System32 \ drivers \ etc \ services file

DB2 default port 50000 listens for connections

DB2 users

All users are operating system DB2 user, and the user password is also bundled with the operating system the user's password.

Under Linux, installing DB2 creates db2inst1, db2fenc1 and dasusr1 three users. Under Windows, the user db2admin created and added to the Administrators group.

Local operating system user is not all DB2 users, we need to add operating system user database in DB2 user management function.

 

In the Windows operating system, which is the command CLP-enabled command line window; in this case, you must start the DB2 command line environment (from the general command window) run db2cmd command.

Windows command line:

Under Linux users need to create db2: Enter su -db2admin to switch.

DB2日常常用运维命令:

1. Start the instance: db2start disabled instance: db2stop 

2, connect to the database: DB User to Connect DB2 US ername the using password;

3. List all instances (db2inst1): db2 list 

4. View sample configuration file: db2 get dbm cfg | more 

5. Update the database manager parameter information: db2 update dbm cfg using para_name para_value 

6. Create a database: db2 create db test 

7. View database configuration parameter information: db2 get db cfg for test | more 

8. Update the configuration database parameters: db2 update db cfg for test using para_name para_value 

9. Remove the database: db2 drop db test 

10. The connection to the database: db2 connect to test 

11. Detailed lists all table spaces: db2 list tablespaces show detail 

12. The information listed in the container: db2 list tablespace containers for dbname show detail 

13. Create a table: db2 ceate table tbname (id integer not null, name char (10)) 

14. List all tables: db2 list tables 

15. Insert Data: db2 insert into tb1 values ​​(1, 'sam'); db2 insert into tb2 values ​​(2, 'smitty'); 

16. The query data: db2 select * from tb1 

17. Data: db2 delete from tb1 where id = 1 

18. Create index: db2 create index idx1 on tb1 (id); 

19. Create view: db2 create view view1 as select id from tb1 

20. Query View: db2 select * from view1 

21. Node Catalog: db2 catalog tcpip node node_name remote server_ip server server_port 

22. The view port number: db2 get dbm cfg | grep SVCENAME 

23. Test attachment node: db2 attach to node_name 

24. View local node: db2 list node direcotry 

25. The anti-node Listings: db2 uncatalog node node_name 

db2 uncatalog node NODE193 

db2 catalog tcpip node NODE_TMP remote 182.119.106.193 server 50000 

26. The database catalog: db2 catalog db db_name as db_alias at node node_name 

27. In view of the database catalog: db2 list db directory 

28. The connection to the database: db2 connect to db_alias user user_name using user_password 

29. Anti database catalog: db2 uncatalog db db_alias 

30. Export data: db2 export to myfile of ixf messages msg select * from tb1 

31. Import Data: db2 import from myfile of ixf messages msg replace into tb1 

32. The database export all tables data: db2move test export 

33. The definition of the database generation: db2look -d db_alias -a -e -m -l -x -f -o db2look.sql 

34. Create a database: db2 create db test1 

35. build definition: db2 -tvf db2look.sql 

36. All the data into the database: db2move db_alias import 

37. Check the reorganization: db2 reorgchk 

TABLE 38. Recombinant tb1: db2 reorg table tb1 

39. The update statistics: the DB2 RUNSTATS O the n-the Table TB1 

40. backup database Test: Backup DB2 D B Test 

41. restore database test: db2 restore db test 

42. View the dynamic sql statement snapshot information: db2 get snapshot for dynamic sql on dbname 

43. Check the table space location: db2pd -db dbname -tablespace

44, backup:  the DB2 bcakup path to db dbname

45、还原:db2 restore database dbname from /tools taken at 20180501030015 to /tools into newdbname redirect

46, see the table space: the DB2 List the Tablespaces

47, roll forward logs to a specified point in time:

db2 "ROLLFORWARD DATABASE dbname TO 2018-05-01-05.00.00.000000 USING LOCAL TIME AND COMPLETE OVERFLOW LOG PATH("/tools")"

48, Aix add a user: smit user

49, see the small machine error message: errpt | more 

50, view, or do a new raid disk array: smitty ssaraid

51, management lv: smitty lvm 

 

Guess you like

Origin www.cnblogs.com/tigergaonotes/p/11079528.html