If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
i want to insert a new row at the end of a table, but if i delete a row before, the DBMS I think, will insert the new row at that position where the the row before was deleted.
is it possible to insert the row every time at the end
You can always insert new rows at the end of the table by doing the following:
alter table <table-name> append;
However, when you select rows from the table without an “order by,” there is no guarantee the last row in the table (physically the last row) will be the last row returned in your answer set with an SQL select statement.
Relational theory requires that if you want rows returned in a particular order, you must use the "order by" clause.
The advantage of “append” is that DB2 will not spend a lot of time looking for free space within the table to insert new rows.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
thank you, i read about append on IBM hp and i think it would solve the problem...
but i can't execute the statement with Zend Studio 5.5 (syntax error):
ALTER TABLE HSL.LOHNLISTE2 append on
is it possible to create a new table with apend on? (without alter table syntax)
Its very much possible. Just append the ALTER TABLE option immediately after the CREATE TAB statement. If your existing tables are not fully loaded, you can definitely choose the following option.
CREATE TABLE TEST.TB_NEW1 (
SOURCETYP CHARACTER(1) NOT NULL,
TRANTYP CHARACTER(1) NOT NULL DEFAULT ' '
)
IN TS_DATA1
INDEX IN TS_INDX1
;
ALTER TABLE TEST.TB_NEW1 APPEND ON
Maybe there is a misconception here. The rows in a table do not have any ordering. You cannot rely on anything, unless you specify an ORDER BY in your query.
The APPEND option mentioned here has only an impact on the physical storage of the rows. It does not guarantee a specific row order in queries.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
I hope that is clear to everyone that while querying DB2 will always return the pages in a random way if you are not ordering them. But the question which is asked here on the top by Stefan is "is it possible to insert the row every time at the end? " May be for that APPEND ON seems to be perfect as Marcus A has suggested.
__________________
Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi
Sure. The question is whether the OP was really referring to the physical order of rows in the table space or the order in which rows are returned by queries. There are a lot of people who confuse both things.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development