How to achieve "insert ignore" using presto?

by cali_green , in category: Third Party Scripts , 5 months ago

How to achieve "insert ignore" using presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 5 months ago

@cali_green 

In Presto, you can achieve the equivalent of "insert ignore" by using the "INSERT ... ON CONFLICT DO NOTHING" syntax. This allows you to insert records into a table and avoid conflicts with existing records by simply ignoring the insert if there is a conflict.


Here's an example of how you can use this syntax in Presto:

1
2
3
INSERT INTO table_name (column1, column2)
VALUES (value1, value2)
ON CONFLICT DO NOTHING;


In this example, "table_name" is the name of the table you want to insert records into, and "column1" and "column2" are the columns you want to insert values into. "value1" and "value2" are the actual values you want to insert.


By using "ON CONFLICT DO NOTHING", Presto will ignore any conflicts that may arise during the insert operation, such as duplicate entries or violations of unique constraints.


It's important to note that Presto does not support all SQL features, so it's possible that the exact syntax may vary slightly depending on the version of Presto you are using. Be sure to refer to the Presto documentation for more information on the specific syntax for your version.

Related Threads:

How to group time column into 5 second intervals and count rows using presto?
How to ignore a folder when using watch with webpack?
How to ignore timezone when parsing using moment.js?
How to ignore white space in string using regex?
How to ignore an character with random numbers using regex?
How to split by newline and ignore blank lines using regex?