|Subject||Re: creating tables within transactions|
> I understand that there is no way of creating and populating a tableConceptually I agree, although there are loads of implementation
> within a single transaction? Dito for creating foreign keys in other
> tables that refer to the newly created table?
questions if it were done that way.
To answer directly your question. You need to commit after making any
DDL changes before executing DML. It is a known source of data weirdness.
> If I'm right, does this have a reason?Some things are bigger than transactions, indexes are global for
instance. What about constraints? If you were to add a unique
constraint, and another user is active, should they be allowed to add
a duplicate to the table before you commit? What about foreign keys?
All of these items are new restrictions other transactions need to
> I must admit it's quite annoyingThe Atomicity part anyway, what about Isolation? You can hardly call a
> sometimes. I mean, it's supposed to be the meaning of transactions to
> bundle tasks that should be performed altogether or not at all - in my
> book this applies to creating a table and creating other database
> objects related to that table.
drop table in isolation and get anything remotely workable.
The approach you need to use is to make a backup of the database
before any DDL changes are made, and if you encounter any issues,
restore the backup. DDL can only be safely made if you are the only
user. Firebird provides several mechanisms for this, the easiest way
is to put the database into shutdown mode.
General running of your system should not require DDL changes,
certainly they may be required if a fix or enhancement is made, so
this approach should work fine.
> I use FB 1.5 on a windows XP machine.