I'm trying to remotely create a table in a Cloud Spanner database using the REST API. The SQL I'm attempting to run is:
CREATE TABLE test (id INT64 NOT NULL) PRIMARY KEY (id)
My initial attempt used the executeSql endpoint, and that resulted in a less than helpful error message:
Syntax error: Expected \")\" or \",\" but got keyword NOT [at 1:29]\nCREATE TABLE test (id INT64 NOT NULL) PRIMARY KEY (id)\n
After a while I discovered the updateDdl endpoint but when I try this by supplying the above query in the statements list, I just get an empty 200 response back and no table is created.
How can I create a table on Cloud Spanner using SQL?
Update
It turns out I was doing everything correct, except a bug in my code meant I wasn't sending a PATCH request, I was sending a GET request! Rather than returning a 405, Spanner happily returns a 200 in this case, but does nothing :(
CREATE TABLE test (id INT64 NOT NULL, PRIMARY KEY (id));
– putu