Reputation: 930
I'm trying to insert data into redshift table using this SQL query:
insert into temp(JSON)({"name":"abc","lname":"xyz"});
but it does not work, I get an error:
Syntax error
Is there any way to insert json data into redshift using a query?
I want to insert a whole json object into query instead of passing key and values
Upvotes: 2
Views: 3615
Reputation: 41
You can use JSON_PARSE('serialized_json') - https://docs.aws.amazon.com/redshift/latest/dg/JSON_PARSE.html
The JSON column should be of the SUPER data type - https://docs.aws.amazon.com/redshift/latest/dg/r_SUPER_type.html
INSERT INTO temp
(JSON)
VALUES
(JSON_PARSE('{"name":"abc","lname":"xyz"}'));
Upvotes: 3
Reputation: 2013
You may simply execute:
insert into temp values('{"name":"abc","lname":"xyz"}');
JSON as a datatype is not supported on Redshift - Amazon Redshift Documentation
Upvotes: 1