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
Copy file name to clipboardExpand all lines: docs/integrate/debezium/tutorial.md
+70-70Lines changed: 70 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ We know we can address several of these points by using a system like CrateDB. C
20
20
21
21
If only we could replicate data from our operational database to CrateDB without having to write custom code… it turns out we can.
22
22
23
-
Enter Debezium,[Debezium](https://debezium.io/)is a standard open-source system, built on top of Kafka, which allows to capture changes on a source database system and replicate them on another system without having to write custom scripts.
23
+
Enter Debezium.[Debezium](https://debezium.io/)is a standard open-source system, built on top of Kafka, which allows to capture changes on a source database system and replicate them on another system without having to write custom scripts.
24
24
25
25
In this post I want to show an example replicating changes on a table from MSSQL to CrateDB.
26
26
@@ -39,10 +39,10 @@ CREATE DATABASE erp;
39
39
GO
40
40
USE erp;
41
41
CREATETABLEdbo.tbltest (
42
-
id INTPRIMARY KEY IDENTITY,
43
-
createdon DATETIME DEFAULT getdate(),
44
-
srcsystem NVARCHAR(max)
45
-
);
42
+
id INTPRIMARY KEY IDENTITY,
43
+
createdon DATETIME DEFAULT getdate(),
44
+
srcsystem NVARCHAR(max)
45
+
);
46
46
```
47
47
Let’s now create an account for Debezium to use to pull the changes:
48
48
@@ -60,15 +60,15 @@ And let’s enable change data capture on our example table:
60
60
EXEC sys.sp_cdc_enable_db;
61
61
ALTERDATABASE erp ADD FILEGROUP cdcfg;
62
62
ALTERDATABASE erp ADD FILE (
63
-
NAME= erp_cdc_file1,
64
-
FILENAME='/var/opt/mssql/data/erp_cdc_file1.ndf'
65
-
) TO FILEGROUP cdcfg;
63
+
NAME= erp_cdc_file1,
64
+
FILENAME='/var/opt/mssql/data/erp_cdc_file1.ndf'
65
+
) TO FILEGROUP cdcfg;
66
66
EXEC sys.sp_cdc_enable_table
67
-
@source_schema='dbo',
68
-
@source_name='tbltest',
69
-
@role_name='debeziumrole',
70
-
@filegroup_name='cdcfg',
71
-
@supports_net_changes=0;
67
+
@source_schema='dbo',
68
+
@source_name='tbltest',
69
+
@role_name='debeziumrole',
70
+
@filegroup_name='cdcfg',
71
+
@supports_net_changes=0;
72
72
```
73
73
74
74
## Setup on the CrateDB side
@@ -98,10 +98,10 @@ And let’s create the structure of the table that will receive the data:
98
98
99
99
```sql
100
100
CREATETABLEdbo.tbltest (
101
-
id INTPRIMARY KEY/* we need the PK definition to match the source table so that this can be used to lookup records when they need to be updated */
102
-
,createdon TIMESTAMP/* CrateDB supports defaults -of course- but because the source table already has a default value we do not need that here */
103
-
,srcsystem TEXT
104
-
);
101
+
id INTPRIMARY KEY,/* we need the PK definition to match the source table so that this can be used to lookup records when they need to be updated */
102
+
createdon TIMESTAMP,/* CrateDB supports defaults -of course- but because the source table already has a default value we do not need that here */
0 commit comments