DB2 12 - Adding data to the end of a table


Volta a página anterior

Volta ao Menu Principal


Desenvolvido por DORNELLES, Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

DB2 12 - Adicionando dados ao final de uma tabela - Adding data to the end of a table

Em um banco de dados relacional, as linhas de uma tabela não são ordenadas e, portanto, a tabela não tem "fim".
No entanto, dependendo do seu objetivo, você pode realizar várias ações para simular a adição de dados ao final de uma tabela.
In a relational database, the rows of a table are not ordered, and thus, the table has no "end".
However, depending on your goal, you can perform several actions to simulate adding data to the end of a table.

Sobre esta tarefa - About this task

Pergunta: - Question:
Como posso adicionar dados ao final de uma tabela? How can I add data to the end of a table?

Resposta: - Answer:
Embora a pergunta seja freqüentemente feita, ela não tem significado em um banco de dados relacional.
As linhas de uma tabela base não são ordenadas; portanto, a tabela não tem um "fim".
Though the question is often asked, it has no meaning in a relational database.
The rows of a base table are not ordered; hence, the table does not have an "end".

No entanto, dependendo de sua meta, você pode realizar uma das seguintes ações para simular a adição de dados ao final de uma tabela:
However, depending on your goal, you can perform one of the following actions to simulate adding data to the end of a table:

  • Se o seu objetivo é obter uma tabela de resultados ordenada de acordo com a data de inserção das linhas, defina um índice exclusivo em uma coluna TIMESTAMP na definição da tabela.
    Em seguida, ao recuperar dados da tabela, use uma cláusula ORDER BY que nomeia essa coluna.
    A inserção mais recente aparece por último.
    If your goal is to get a result table that is ordered according to when the rows were inserted, define a unique index on a TIMESTAMP column in the table definition.
    Then, when you retrieve data from the table, use an ORDER BY clause that names that column.
    The newest insert appears last.

  • Se o seu objetivo é que o Db2 insira linhas no próximo espaço livre disponível, sem preservar a ordem de clustering, especifique a opção APPEND YES ao criar ou alterar a tabela.
    Especificar essa opção pode reduzir o tempo necessário para inserir linhas, porque o Db2 não gasta tempo procurando por espaço livre.
    If your goal is for Db2 to insert rows in the next available free space, without preserving clustering order, specify the APPEND YES option when you create or alter the table.
    Specifying this option might reduce the time it takes to insert rows, because Db2 does not spend time searching for free space.

Tópico pai: Adding and modifying data from application programs



© Copyright IBM Corp.