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.

 
Go Back  dBforums > Database Server Software > DB2 > problem with deleting rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-08, 01:30
gochtel gochtel is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
problem with deleting rows

Hello,

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

thanks

Stefan

sry for my english
Reply With Quote
  #2 (permalink)  
Old 11-28-08, 02:20
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #3 (permalink)  
Old 11-28-08, 04:19
gochtel gochtel is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
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)
Reply With Quote
  #4 (permalink)  
Old 11-28-08, 04:45
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
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


Thanks,
Jayanta

Last edited by JAYANTA_DATTA; 11-28-08 at 07:35.
Reply With Quote
  #5 (permalink)  
Old 11-28-08, 07:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #6 (permalink)  
Old 11-28-08, 07:38
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
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
Reply With Quote
  #7 (permalink)  
Old 11-28-08, 07:53
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #8 (permalink)  
Old 11-28-08, 22:56
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
Why are you concerned with the placement? It doesn't sound like this is due to any performance type issue, so why would it matter?
Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On