> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# كيفية إنشاء جدول يمكنه تنفيذ استعلامات على عدة عناقيد بعيدة

> كيفية إنشاء جدول يمكنه تنفيذ استعلامات على عدة عناقيد بعيدة

{frontMatter.description}

***

<div id="question">
  ## السؤال
</div>

كيف يمكنني إنشاء جدول يتيح الاستعلام عن البيانات من عناقيد أو مثيلات أخرى؟

<div id="answer">
  ## الإجابة
</div>

فيما يلي مثال بسيط لاختبار الوظيفة.

في هذا المثال، يُستخدم ClickHouse Cloud، غير أن المثال يعمل أيضاً مع clusters مستضافة ذاتياً.
ستحتاج الأهداف إلى التعديل لتعكس عناوين URL/المضيفين/DNS الخاصة بعقدة الهدف أو load balancer.

في المجموعة A:

```
./clickhouse client --host clusterA.us-west-2.aws.clickhouse.cloud --secure --password 'Password123!'
```

أنشئ قاعدة البيانات:

```
create database db1;
```

أنشئ الجدول:

```
 CREATE TABLE db1.table1_remote1
(
    `id` UInt32,
    `timestamp_column` DateTime,
    `string_column` String
)
ENGINE = MergeTree()
ORDER BY id;
```

أدرج بعض الصفوف النموذجية:

```
insert into db1.table1_remote1
values
(1, '2023-09-29 00:01:00', 'a'),
(2, '2023-09-29 00:02:00', 'b'),
(3, '2023-09-29 00:03:00', 'c');
```

في المجموعة B:

```
./clickhouse client --host clusterB.us-east-2.aws.clickhouse.cloud --secure --password 'Password123!'
```

أنشئ قاعدة البيانات:

```
create database db1;
```

أنشئ الجدول:

```
CREATE TABLE db1.table1_remote2
(
    `id` UInt32,
    `timestamp_column` DateTime,
    `string_column` String
)
ENGINE = MergeTree()
ORDER BY id;
```

أدرج صفوفاً نموذجية:

```
insert into db1.table1_remote1
values
(4, '2023-09-29 00:04:00', 'x'),
(5, '2023-09-29 00:05:00', 'y'),
(6, '2023-09-29 00:06:00', 'z');
```

في المجموعة C:
\*ستُستخدم هذه المجموعة لتجميع البيانات من المجموعتين الأخريتين، غير أنه يمكن استخدامها أيضاً كمصدر.

```
./clickhouse client --host clusterC.us-west-2.aws.clickhouse.cloud --secure --password 'Password123!'
```

أنشئ قاعدة البيانات:

```
create database db1;
```

أنشئ الجداول البعيدة باستخدام remoteSecure() للاتصال بالكلاسترات الأخرى.
تعريف جدول الكلاستر البعيد A:

```
CREATE TABLE db1.table1_remote1_main
(
    `id` UInt32,
    `timestamp_column` DateTime,
    `string_column` String
) AS remoteSecure('clusterA.us-west-2.aws.clickhouse.cloud:9440', 'db1.table1_remote1', 'default', 'Password123!');
```

تعريف جدول المجموعة العنقودية B البعيدة:

```
CREATE TABLE db1.table1_remote2_main
(
    `id` UInt32,
    `timestamp_column` DateTime,
    `string_column` String
) AS remoteSecure('clusterB.us-east-2.aws.clickhouse.cloud:9440', 'db1.table1_remote2', 'default', 'Password123!')
```

أنشئ Merge table لتجميع النتائج:

```
create table db1.table1_merge_remote
(
  id UInt32,
  timestamp_column DateTime,
  string_column String
)
engine = Merge('db1', 'table.\_main');
```

اختبر النتائج:

```
clickhouse-cloud :) select * from db1.table1_merge_remote;

SELECT *
FROM db1.table1_merge_remote

Query id: 46b6e741-bbd1-47ed-b40e-69ddb6e0c364

┌─id─┬────timestamp_column─┬─string_column─┐
│  1 │ 2023-09-29 00:01:00 │ a             │
│  2 │ 2023-09-29 00:02:00 │ b             │
│  3 │ 2023-09-29 00:03:00 │ c             │
└────┴─────────────────────┴───────────────┘
┌─id─┬────timestamp_column─┬─string_column─┐
│  4 │ 2023-09-29 00:04:00 │ x             │
│  5 │ 2023-09-29 00:05:00 │ y             │
│  6 │ 2023-09-29 00:06:00 │ z             │
└────┴─────────────────────┴───────────────┘

6 rows in set. Elapsed: 0.275 sec. 
```

لمزيد من المعلومات:

* [دالة الجدول remote](/docs/ar/reference/functions/table-functions/remote)
* [محرك جدول Merge](/docs/ar/reference/engines/table-engines/special/merge)
