【DB2基础】DB2编目和数据库连接

1.编目节点和编目数据库

编目(Catalog),是在本地或远程建立客户端到服务器的数据库连接的过程。其目的在于获取编目信息,即生成用来访问数据库的目录。

系统数据库目录包含一个列表和指针,通过目录可以使 DB2 能够找到已知的数据库,无论它们是在本地系统上,还是在远程系统上。如果没有编目信息,应用程序就无法连接数据库,所以在使用 DB2 时必须要先进行编目。编目包括以下两个过程:

节点编目:将服务器映射到客户端。

数据库编目:将服务器实例下的数据库映射到客户端。

//增加结点编目:
  db2 catalog tcpip node 结点名字 remote 结点所在ip地址 server 50000
//查看结点编目:
  db2 list node directory
//删除结点编目:
  db2 uncatalog node 结点别名

//增加数据库编目:
  db2 catalog db 远程数据库名字 as 数据库别名 at node 结点名字
//查看数据库编目:
  db2 list db directory
//删除数据库编目:
  db2 uncatalog db数据库别名

 2.连接数据库

当完成了节点编目与数据库编目后,要将客户端与服务器的数据库相连接。

db2 connect 数据库名 user 用户名 using 密码

3.应用实例

db2 catalog tcpip node etlplus remote 192.168.1.111 serer 5004
db2 catalog db etlplus as etlplus at node etlplus
db2 connect to etlplus user etlplus using etlplus@123

猜你喜欢

转载自www.cnblogs.com/badboy200800/p/10369482.html