# • 导入实时表

如果你决定从\[普通模式]\(../../../Creating\_a\_table/Local\_tables.md#Defining-table-schema-in-config-%28Plain mode%29)迁移到[实时模式](https://vergil-lai.gitbook.io/manticoresearch-manual-zh/data_creation_and_modification/cong-wai-bu-cun-chu-tian-jia-shu-ju/cong-biao-zhong-tian-jia-shu-ju/pages/qniF4jUUvvfE0wps48dr#Online-schema-management-\(RT-mode\))或在其他情况下，可以使用`IMPORT TABLE`语句将以普通模式构建的实时表和渗透表导入到运行实时模式的Manticore中。其一般语法如下：

```sql
IMPORT TABLE table_name FROM 'path'
```

其中'path'参数必须设置为：`/your_backup_folder/your_backup_name/data/your_table_name/your_table_name`

```bash
mysql -P9306 -h0 -e 'create table t(f text)'

mysql -P9306 -h0 -e "backup table t to /tmp/"

mysql -P9306 -h0 -e "drop table t"

BACKUP_NAME=$(ls /tmp | grep 'backup-' | tail -n 1)

mysql -P9306 -h0 -e "import table t from '/tmp/$BACKUP_NAME/data/t/t'

mysql -P9306 -h0 -e "show tables"
```

执行此命令会将指定表的所有表文件复制到[data\_dir](/manticoresearch-manual-zh/fu-wu-qi-she-zhi/searchd.md#data_dir)中。所有外部表文件（如词形、例外和停用词文件）也将复制到相同的`data_dir`。

`IMPORT TABLE`具有以下限制：

* 原始配置文件中指定的外部文件路径必须是绝对路径。
* 仅支持实时表和渗透表。
* 普通表需要预先（在普通模式下）通过[ATTACH TABLE](/manticoresearch-manual-zh/data_creation_and_modification/cong-wai-bu-cun-chu-tian-jia-shu-ju/cong-biao-zhong-tian-jia-shu-ju/attaching_one_table_to_another.md)转换为实时表。

请注意，`IMPORT TABLE`命令不支持5.0.0版本之前创建的表。

## indexer --print-rt

如果无法使用上述方法将普通表迁移到实时表，则可以使用\`indexer --print-rt\`直接从普通表中转储数据，而无需将其转换为实时表类型，然后直接从命令行将转储的数据导入到实时表。

此方法有一些限制：

* 仅支持基于SQL的数据源。
* 不支持MVA（多值属性）。

```bash
/usr/bin/indexer --rotate --config /etc/manticoresearch/manticore.conf --print-rt my_rt_index my_plain_index > /tmp/dump_regular.sql

mysql -P $9306 -h0 -e "truncate table my_rt_index"

mysql -P 9306 -h0 < /tmp/dump_regular.sql

rm /tmp/dump_regular.sql
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vergil-lai.gitbook.io/manticoresearch-manual-zh/data_creation_and_modification/cong-wai-bu-cun-chu-tian-jia-shu-ju/cong-biao-zhong-tian-jia-shu-ju/importing_table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
