• Visitors can check out the Forum FAQ by clicking this link. You 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. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reply to: Oracle question

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Oracle question"

Collapse

  • DBA_bloke
    replied
    If no constraints, then, after CTAS:

    "DROP TABLE orginal_table PURGE;"
    then:
    "ALTER TABLE backup_table RENAME TO original_table;"

    Leave a comment:


  • Moose423956
    replied
    Originally posted by TheFaQQer View Post
    I guess it didn't go well
    It was a "just in case" question. Just done the delete, and it went okay.

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by Moose423956 View Post
    Supplementary question.

    Given that I have gone for the "CREATE TABLE..." option, what code would I need to write to copy them back into the original table from the backup table, after deleting them from the original table?

    I'm going to have a go at writing it...please don't laugh if I get it wrong.

    INSERT INTO original_table
    SELECT * FROM backup_table

    Is it that simple?
    I guess it didn't go well

    Yes, that code should do it.

    Leave a comment:


  • lilelvis2000
    replied
    It looks okay to me....unless of course there is a sequence counter and you need to preserve the sequence number. In which case you'll need to turn that off.

    Otherwise looks good...but I'm not a guru.

    Leave a comment:


  • Moose423956
    replied
    Supplementary question.

    Given that I have gone for the "CREATE TABLE..." option, what code would I need to write to copy them back into the original table from the backup table, after deleting them from the original table?

    I'm going to have a go at writing it...please don't laugh if I get it wrong.

    INSERT INTO original_table
    SELECT * FROM backup_table

    Is it that simple?

    Leave a comment:


  • lilelvis2000
    replied
    Gosh! You gurus.

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by DBA_bloke View Post
    Agreed.
    Cor, that OCP is really paying off now!

    Leave a comment:


  • DBA_bloke
    replied
    Originally posted by TheFaQQer View Post
    But if there are "lots" of records, then there is a chance that you might blow the rollback segment.

    And, you may need to commit before seeing the impact (e.g. deleting data and then check that your workflow / form / report / etc works.)
    Agreed.

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by lilelvis2000 View Post
    well, if you don't commit then no one (but you) can see your changes.

    So do your work. Then test everything. checksum. if all okay, commit. otherwise rollback and start all over.

    If you are thinking Oracle works like Access or SQL Server - it don't - it works much better.
    But if there are "lots" of records, then there is a chance that you might blow the rollback segment.

    And, you may need to commit before seeing the impact (e.g. deleting data and then check that your workflow / form / report / etc works.)

    Leave a comment:


  • lilelvis2000
    replied
    well, if you don't commit then no one (but you) can see your changes.

    So do your work. Then test everything. checksum. if all okay, commit. otherwise rollback and start all over.

    If you are thinking Oracle works like Access or SQL Server - it don't - it works much better.

    Leave a comment:


  • DBA_bloke
    replied
    Originally posted by TheFaQQer View Post
    I was thinking along the lines of quickly being able to recover from an error without anyone noticing! Exp/Imp might be too visible!!
    I like your sneaky style! 10 points.

    Leave a comment:


  • TheFaQQer
    replied
    Originally posted by DBA_bloke View Post
    Use Oracle export, why clog-up the DB with table copies? You'll forget about them - I do!

    Oracle Export:
    exp userid=<schema-owner> file=MyFile log=MyLog compress=n consistent=y recordlength=65000 buffer=512000 direct=y tables=table1,table2, etc.

    You'll be prompted for the schema-owner's database password.
    I was thinking along the lines of quickly being able to recover from an error without anyone noticing! Exp/Imp might be too visible!!

    Leave a comment:


  • DBA_bloke
    replied
    Use Oracle export, why clog-up the DB with table copies? You'll forget about them - I do!

    Oracle Export:
    exp userid=<schema-owner> file=MyFile log=MyLog compress=n consistent=y recordlength=65000 buffer=512000 direct=y tables=table1,table2, etc.

    You'll be prompted for the schema-owner's database password.

    Leave a comment:


  • TheFaQQer
    replied
    CREATE TABLE blah AS ( SELECT * FROM original );

    Creates a new backup table with them all in.

    Leave a comment:


  • Moose423956
    started a topic Oracle question

    Oracle question

    Before I run a process to delete a lot (thousands) of records from an Oracle table, is there an easy way of backing those records up first in case it all goes wrong, so they can be restored if necessary? Like copying the records to a text file or something like that?

    I'm relatively new to Oracle, so be gentle with me.
Working...
X