Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Posts
    1

    Question Unanswered: How to archive a table into another database?

    Hi all, i am new.

    how can i do this?
    for example i have a table called "cdr" in database "thismonth"

    i want to archive the data in the table month by month to another table "old_cdr" in database called "lastmonth"

    for example, today is 2 July, and data of June should archived into table "old_cdr", and no June data should be in table "cdr"

    how can i do this automatically?
    thanks all.

  2. #2
    Join Date
    Nov 2006
    Posts
    82
    I think u should look for triggers and module dblink.
    All u need u can find on http://postgresql.org

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Another approach might be to create a temp table, copy "old" records to the temp table, backup the temp table data to a file, then restore the temp table data to the archive database. After each step succeeds, you could delete the data from the "source".

    In any event, after the records are removed from the parent table, be sure to vacuum/analyze the parent table.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •