Databricks JDBC write to table with PK column, error, key not found.

JamesY
New Contributor III

Hello, I am trying to write data to table, it works find before, but after I recreated the table with one column as PK, there is an error.

Unable to write into the A_Table table....key not found: id

 What is the correct way of doing this?
PK column:   [ID] [bigint] IDENTITY(1,1) PRIMARY KEY NOT NULL

NandiniN
Databricks Employee
Databricks Employee

Looks like the primary key column ID is not being found during the write operation.

Kindly verify the schema. 

Use a command like below to create the table with id as the primary key.

CREATE TABLE A_Table ( ID BIGINT IDENTITY(1,1) PRIMARY KEY NOT NULL, -- other columns );

Documentations:

https://docs.databricks.com/ja/sql/language-manual/sql-ref-syntax-ddl-create-table-using.html

https://docs.databricks.com/ja/sql/language-manual/sql-ref-syntax-ddl-create-table-constraint.html