---
title: "DB2 的表在删除字段后 表会挂起 需要执行 reorg命令"
author: "dannyhz"
date: "2017-09-19T17:24:23Z"
tags: []
categories: ["数据库"]
slug: "db2-reorg"
draft: false
lastmod: "2017-09-19T17:24:23Z"
id: 2393732
url: "https://dannyhz.iteye.com/blog/2393732"
---

DB2 的表在删除字段后 表会挂起 需要执行 reorg命令

步骤如下:

通过ssh 登陆到 192.168.1.74 数据库所在服务器

工具: Xshell 5
连接之后：

> 
> 
> Connecting to 192.168.1.74:22...
> Connection established.
> 
> 


db2 安装的目录在

/opt/ibm/db2/V11.1/

进入bin
cd bin

命令
./db2 list db directory


> 
> 
> System Database Directory
> 
>  Number of entries in the directory = 2
> 
> Database 1 entry:
> 
>  Database alias                       = MPOS
>  Database name                        = MPOS
>  Local database directory             = /home/db2inst1
>  Database release level               = 14.00
>  Comment                              =
>  Directory entry type                 = Indirect
>  Catalog database partition number    = 0
>  Alternate server hostname            =
>  Alternate server port number         =
> 
> Database 2 entry:
> 
>  Database alias                       = IBBDKUSR
>  Database name                        = IBBDKUSR
>  Local database directory             = /home/db2inst1
>  Database release level               = 14.00
>  Comment                              =
>  Directory entry type                 = Indirect
>  Catalog database partition number    = 0
>  Alternate server hostname            =
>  Alternate server port number         =
> 
> 
> 

先连接上db2：
./db2 connect to IBBDKUSR user mpos using JYCDB2


> 
> 
> 
>    Database Connection Information
> 
>  Database server        = DB2/LINUXX8664 11.1.1.1
>  SQL authorization ID   = MPOS
>  Local database alias   = IBBDKUSR
> 
> 
> 


再执行 表整理
./db2 reorg table withholding_test.merchant



> 
> 
> [mpos@localhost bin]$ ./db2 reorg table withholding_test.merchant;
> DB20000I  The REORG command completed successfully.
> 
> 
>