Subject | Re: [firebird-support] Re: Should this work? |
---|---|
Author | Ivan Prenosil |
Post date | 2005-04-11T07:46:48Z |
>> > to create quickly a table with a lot of rows, I usually do a:You do not have to fear, because there are several easy workarounds.
>> >
>> > INSERT INTO the_table
>> > SELECT * FROM the_table;
>>
>> In Firebird, that will (eventually) create an infinite number of rows.
>> The select doesn't stop with the rows that existed before the insert
>> started, but continues storing one more new row for each row it stores
>> until you run out of patience, time, or disk space. It's a bug of long
>> standing - it becamea a bug in 1982 when the first SQL standard was
>> published. Before that, it was just a quirk.
>
> Thanks for the quick reply.
> I did fear that this would be the answer :)
* Force the whole select to be performed before inserting starts.
It can be achieved by sorting inserted rows (I think this syntax requires FB>=1.5)
INSERT INTO the_table
SELECT * FROM the_table ORDER BY any_field;
* Force list of inserted rows to be created first. If you have indexed column,
and Where clause use it, then Firebird will first scan that index and create
list of internal db_key values.
INSERT INTO the_table
SELECT * FROM the_table WHERE some_indexd_field >= 0;
There should be document about this problem on http://www.cvalde.net/
Ivan
http://www.volny.cz/iprenosil/interbase/