Enjoying Database Administration

12.1.09

FOR READ ONLY

The FOR READ ONLY clause is a useful amendment to SQL statements. It can be used in a number of ways and can differ between platforms. Specifically, the FOR READ ONLY clause can be appended to a SQL full select statement, or cursor in order to prevent changes to the data in the result set.

In the case of a full select statement, the FOR READ ONLY prevents modification of the data in the results set. This of course means that you cannot use this clause with an UPDATE or DELETE statement, as those statements call for modification of the data which is prevented by the statement.

In the case of cursors this clause can prevent the inadvertent modification of the table data where it is only desired to modify the data for output.

No comments:

Post a Comment