Database Reference
In-Depth Information
Deleting a row
Deleting a row is a little more complicated than all the DROP statements that we have seen
so far. All you have to do is specify the column or a member of a collection to delete, fol-
lowed by table name and optionally, you can specify TIMESTAMP if you wanted it to be a
check. And finally, you need to identify the row. Here's the scheme:
DELETE [ column_identifier ]
FROM table_name
[ USING TIMESTAMP ts_in_microsec ]
WHERE row_identifier
[ IF { EXISTS | condition [ AND condition [ AND condition
... ] ] } ];
Here are some examples, continuing from the previous section:
# Delete an element from a collection
DELETE movies[1] FROM update_demo WHERE id = 1;
SELECT * FROM update_demo;
id | movies | name
----+-------------------------------+---------------
10 | ['Star Wars', 'Donnie darko'] | null
1 | ['Beautiful Mind', 'Amelie'] | Movie Website
(2 rows)
# Delete using the lightweight transaction
DELETE name FROM update_demo WHERE id = 1 IF movies[1] =
'Amelie';
Search WWH ::




Custom Search