You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,70 +11,133 @@ import EEFeature from '@site/src/components/EEFeature';
11
11
12
12
<EEFeaturefeatureName='ATTACH TABLE'/>
13
13
14
-
Attaches an existing table to another one. The command moves the data and schema of a table from one database to another, but without actually copying the data. Instead, it creates a link that points to the original table data for accessing the data.
14
+
ATTACH TABLE creates a read-only link to existing table data without copying it. This command is ideal for data sharing across environments, especially when migrating from a private Databend deployment to [Databend Cloud](https://www.databend.com).
15
15
16
-
- Attach Table enables you to seamlessly connect a table in the cloud service platform to an existing table deployed in a private deployment environment without the need to physically move the data. This is particularly useful when you want to migrate data from a private deployment of Databend to [Databend Cloud](https://www.databend.com) while minimizing the data transfer overhead.
16
+
## Key Features
17
17
18
-
- The attached table operates in READ_ONLY mode. In this mode, changes in the source table are instantly reflected in the attached table. However, the attached table is exclusively for querying purposes and does not support updates. This means INSERT, UPDATE, and DELETE operations are not allowed on the attached table; only SELECT queries can be executed.
18
+
-**Zero-Copy Data Access**: Links to source data without physical data movement
19
+
-**Real-Time Updates**: Changes in the source table are instantly visible in attached tables
20
+
-**Read-Only Mode**: Only supports SELECT queries (no INSERT, UPDATE, or DELETE operations)
21
+
-**Column-Level Access**: Optionally include only specific columns for security and performance
-`<column_list>`: An optional, comma-separated list of columns to include from the source table, allowing users to specify only the necessary columns instead of including all of them. If not specified, all columns from the source table will be included.
27
29
28
-
- Renaming an included column in the source table updates its name in the attached table, and it must be accessed using the new name.
29
-
- Dropping an included column in the source table makes it inaccessible in the attached table.
30
-
- Changes to non-included columns, such as renaming or dropping them in the source table, do not affect the attached table.
30
+
### Parameters
31
31
32
-
-`<source_table_data_URI>` represents the path to the source table's data. For S3-like object storage, the format is `s3://<bucket-name>/<database_ID>/<table_ID>`, for example, _s3://databend-toronto/1/23351/_, which represents the exact path to the table folder within the bucket.
32
+
-**`<target_table_name>`**: Name of the new attached table to create
33
33
34
-

34
+
-**`<column_list>`**: Optional list of columns to include from the source table
35
+
- When omitted, all columns are included
36
+
- Provides column-level security and access control
37
+
- Example: `(customer_id, product, amount)`
35
38
36
-
To obtain the database ID and table ID of a table, use the [FUSE_SNAPSHOT](../../../20-sql-functions/16-system-functions/fuse_snapshot.md) function. In the example below, the part **1/23351/** in the value of _snapshot_location_ indicates that the database ID is **1**, and the table ID is **23351**.
39
+
-**`<source_table_data_URI>`**: Path to the source table data in object storage
-`CONNECTION` specifies the connection parameters required for establishing a link to the object storage where the source table's data is stored. The connection parameters vary for different storage services based on their specific requirements and authentication mechanisms. For more information, see [Connection Parameters](../../../00-sql-reference/51-connect-parameters.md).
47
+
Use the [FUSE_SNAPSHOT](../../../20-sql-functions/16-system-functions/fuse_snapshot.md) function to get the database and table IDs:
57
48
58
-
## Tutorials
49
+
```sql
50
+
SELECT snapshot_location FROM FUSE_SNAPSHOT('default', 'employees');
51
+
-- Result contains: 1/23351/_ss/... → Path is s3://your-bucket/1/23351/
52
+
```
59
53
60
-
-[Linking Tables with ATTACH TABLE](/tutorials/databend-cloud/link-tables)
54
+
## Data Sharing Benefits
55
+
56
+
### How It Works
57
+
58
+
```
59
+
Object Storage (S3, MinIO, Azure, etc.)
60
+
┌─────────────┐
61
+
│ Source Data │
62
+
└──────┬──────┘
63
+
│
64
+
┌───────────────────────┼───────────────────────┐
65
+
│ │ │
66
+
▼ ▼ ▼
67
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
68
+
│ Marketing │ │ Finance │ │ Sales │
69
+
│ Team View │ │ Team View │ │ Team View │
70
+
└─────────────┘ └─────────────┘ └─────────────┘
71
+
```
72
+
73
+
### Key Advantages
74
+
75
+
| Traditional Approach | Databend ATTACH TABLE |
76
+
|---------------------|----------------------|
77
+
| Multiple data copies | Single copy shared by all |
78
+
| ETL delays, sync issues | Real-time, always current |
79
+
| Complex maintenance | Zero maintenance |
80
+
| More copies = more security risk | Fine-grained column access |
81
+
| Slower due to data movement | Full optimization on original data |
82
+
83
+
### Security and Performance
84
+
85
+
-**Column-Level Security**: Teams see only the columns they need
86
+
-**Real-Time Updates**: Source changes instantly visible in all attached tables
87
+
-**Strong Consistency**: Always see complete data snapshots, never partial updates
88
+
-**Full Performance**: Inherit all source table indexes and optimizations
61
89
62
90
## Examples
63
91
64
-
This example creates an attached table, which includes all columns from a source table stored in AWS S3:
0 commit comments