Does the SQL standard specify the locking order for a multi-table query?
For example, given:
SELECT department.id FROM permissions, terminals, departme
I can give you an answer for DB2, but I think that this should be similar for other databases as well. First of all, everything depends on the locksize parameter of your tables. This parameter defines what is being locked. You can have locksize = table, page or row. So, depending on locksize of each table, the database will lock the object (table, page or row) that is used to fetch data for the cursor. So the order of locks being created will be specified by the access path, which depends on the optimizer.