Share
 
 

Deletion

It is possible to delete objects using SQL by using the DELETE keyword. In general the way that objects are deleted is very similar to the way in which they can be selected or deselected.

To delete objects from the default table for which a given expression is true, the keywords DELETE WHERE should be used, followed by the appropriate expression e.g. DELETE WHERE x > 10000.

This will use the default table and the default selection behaviour. To override the default table the keywords DELETE FROM followed by the table name followed by WHERE followed by the expression should be used e.g. DELETE FROM [All Links] WHERE width > 100.

As with selection and deselection it is possible to override the default selection behaviour by using the keywords ALL and SELECTED e.g. DELETE ALL WHERE x > 10000, DELETE SELECTED WHERE y > 20000.

It is possible to override the default selection behaviour and the default table e.g. DELETE ALL FROM [All Links] WHERE width > 100.

In the unlikely event you wish to delete all objects from the current table you can say DELETE ALL. DELETE SELECTED will delete all selected objects from the current table. The keyword DELETE on its own will follow the default selection behaviour and either delete all or selected objects depending on whether or not the check-box is checked.

Similarly, it is possible to delete all or selected objects from another table by using the syntax described above for deleting some objects from a table but omitting the keyword WHERE and the expression following it e.g. DELETE ALL FROM [All Links], DELETE SELECTED FROM [CCTV Survey], DELETE FROM Node.

The final one of these examples will follow the default selection behaviour and either delete all objects or all selected objects from the nodes table depending on whether or not the check-box is checked.

As with selection and deselection it is possible to delete objects in scenarios e.g.

DELETE ALL FROM [All Nodes] IN SCENARIO 'west' WHERE x < 644000. It is also possible to restrict the number of objects deleted with a GROUP BY clause in conjunction with the TOP and BOTTOM keywords.

It is possible to delete from structure blobs by saying

DELETE FROM [Table Name].blob_name WHERE condition

This deletes the contents of the blobs but not the object in the table. The condition may be omitted. The condition may include fields in the blob and fields in the object i.e. you can selectively delete rows in the blobs based on a combination of conditions for the blob and the object.

Was this information helpful?