

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 选择规则和操作
<a name="CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Selections"></a>

通过使用表映射，可通过选择规则和操作来指定要使用的表、视图和架构。对于使用选择规则类型的表映射规则，您可应用以下值。

**警告**  
请勿在这些规则中包含任何敏感数据。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Selections.html)

**Example 迁移架构中的所有表**  
以下示例将所有表从源中名为 `Test` 的架构中迁移到目标端点。  

```
{
    "rules": [
        {
            "rule-type": "selection",
            "rule-id": "1",
            "rule-name": "1",
            "object-locator": {
                "schema-name": "Test",
                "table-name": "%"
            },
            "rule-action": "include"
        }
    ]
}
```

**Example 迁移架构中的一些表**  
以下示例将所有表（以 `DMS` 开头的表除外）从源中名为 `Test` 的架构中迁移到目标端点。  

```
{
    "rules": [
        {
            "rule-type": "selection",
            "rule-id": "1",
            "rule-name": "1",
            "object-locator": {
                "schema-name": "Test",
                "table-name": "%"
            },
            "rule-action": "include"
        },
        {
            "rule-type": "selection",
            "rule-id": "2",
            "rule-name": "2",
            "object-locator": {
                "schema-name": "Test",
                "table-name": "DMS%"
            },
            "rule-action": "exclude"
        }
    ]
}
```

**Example 在单个架构中迁移指定的单个表**  
以下示例将源中 `NewCust` 架构中的 `Customer` 表迁移到目标端点。  

```
{
    "rules": [
        {
            "rule-type": "selection",
            "rule-id": "1",
            "rule-name": "1",
            "object-locator": {
                "schema-name": "NewCust",
                "table-name": "Customer"
            },
            "rule-action": "explicit"
        }
    ]
}
```
您可以通过指定多个选择规则在多个表和架构上显式选择。

**Example 按设定顺序迁移表**  
表和视图根据其加载顺序值进行迁移，较高的值在迁移序列中获得优先级。以下示例会迁移两个表，`loadfirst`（优先级值为 2）和 `loadsecond`（优先级值为 1），迁移任务将首先处理 `loadfirst` 表，然后再继续处理 `loadsecond` 表。这种优先级划分机制可确保在迁移过程中遵循数据库对象之间的依赖关系。  

```
{
    "rules": [
        {
            "rule-type": "selection",
            "rule-id": "1",
            "rule-name": "1",
            "object-locator": {
                "schema-name": "Test",
                "table-name": "loadsecond"
            },
            "rule-action": "include",
            "load-order": "1"
        },
        {
            "rule-type": "selection",
            "rule-id": "2",
            "rule-name": "2",
            "object-locator": {
                "schema-name": "Test",
                "table-name": "loadfirst"
            },
            "rule-action": "include",
            "load-order": "2"
        }
    ]
}
```

**注意**  
`load-order` 适用于表初始化。如果 `MaxFullLoadSubTasks` 大于 1，则连续表的加载不会等待上一个表的加载完成。

**Example 迁移架构中的部分视图**  
以下示例将部分视图从源中名为 `Test` 的架构迁移到目标中等同的表。  

```
{
   "rules": [
        {
           "rule-type": "selection",
           "rule-id": "2",
           "rule-name": "2",
           "object-locator": {
               "schema-name": "Test",
               "table-name": "view_DMS%",
               "table-type": "view"
            },
           "rule-action": "include"
        }
    ]
}
```

**Example 迁移架构中的所有表和视图**  
以下示例将所有表和视图从源中名为 `report` 的架构迁移到目标中等同的表。  

```
{
   "rules": [
        {
           "rule-type": "selection",
           "rule-id": "3",
           "rule-name": "3",
           "object-locator": {
               "schema-name": "report",
               "table-name": "%",
               "table-type": "all"
            },
           "rule-action": "include"
        }
    ]
}
```