If no constraints, then, after CTAS:
"DROP TABLE orginal_table PURGE;"
then:
"ALTER TABLE backup_table RENAME TO original_table;"
- 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.
Logging in...
Previously on "Oracle question"
Collapse
-
It was a "just in case" question. Just done the delete, and it went okay.Originally posted by TheFaQQer View PostI guess it didn't go well
Leave a comment:
-
I guess it didn't go wellOriginally posted by Moose423956 View PostSupplementary 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?
Yes, that code should do it.
Leave a comment:
-
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:
-
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:
-
Agreed.Originally posted by TheFaQQer View PostBut 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:
-
But if there are "lots" of records, then there is a chance that you might blow the rollback segment.Originally posted by lilelvis2000 View Postwell, 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.
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:
-
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:
-
I was thinking along the lines of quickly being able to recover from an error without anyone noticing! Exp/Imp might be too visible!!Originally posted by DBA_bloke View PostUse 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:
-
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:
-
CREATE TABLE blah AS ( SELECT * FROM original );
Creates a new backup table with them all in.
Leave a comment:
-
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.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Leave a comment: