I have following table called 'devices':
userid | deviceid | devicedata | userdata
All columns are varchars and userid+deviceid is the primary key.
Inserting one row in to table seems working:
INSERT INTO devices (userid, deviceid, devicedata, userdata)
VALUES ('user7', 'deviceid1', 'devicedata7', 'userdata1');
But following doesn't work:
INSERT INTO devices (userid, deviceid, devicedata, userdata)
VALUES (('user8', 'deviceid1', 'devicedata8', 'userdata1'),
('user9', 'deviceid1', 'devicedata9', 'userdata1'));
I the get following error:
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Unmatched column names/values"
How can I insert multiple rows with one line of INSERT? Is it possible? I know that there is batching option.
Just make two requests or unlogged batch if you really need to, but I would recommend just making 2 different async requests, theres little to negative effects in batching them.