Oracle migrate data from one database to another [duplicate] - oracle

This question already has answers here:
Copy database to the local machine - ORACLE
(2 answers)
Closed last month.
How to copy data from one data base to another database table using script like procedure, cursor etc.
I am using oracle-sql developer.

Doing it using a script like procedure, cursor etc. is not the way to do it. Oracle offers Data Pump export and import utilities which are designed to move data around, so I'd suggest you to use them.

Related

Restore the truncated table data in Oracle [duplicate]

This question already has an answer here:
Use of FLASHBACK in Oracle
(1 answer)
Closed 6 years ago.
I am new to Oracle Advance concepts, In my application I have accidentally "truncate" the data. I am facing difficulty to
restore the truncated data. I googled about it alot, I found there is "FLASHBACK" command from oracle 10g. I tried it using timestamp approach in flashback
but I am getting the following error:
Error: The table definition has changed.
Could any body tell me how to get back my truncated table data?
Is it possible? If it is Please let me know the procedure to get back the data.
The error message is pretty clear. FLASHBACK is not available if you had DDL operations on the table (add or drop column, add or drop constraint, etc.) It's right there in the first paragraph in the documentation. http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9012.htm As Tim suggests - this is where backing up your data would have helped.
Edit: To be very precise, the wording in the Oracle documentation is (with my emphasis): Oracle Database cannot restore a table to an earlier state across any DDL operations that change the structure of the table. So adding or dropping a column will prevent the use of FLASHBACK since they change the structure of the table. TRUNCATE does not, so TRUNCATE by itself does not prevent FLASHBACK (although TRUNCATE is a DDL operation). I got carried away in the first paragraph with "add or drop constraint" - I actually don't know if that will prevent FLASHBACK; one can find out by experimenting.

Is it possible in oracle to trigger a SAS program after an insert or update on oracle table?

I'm new to oracle and I saw Oracle triggers can trigger some action after an update or insert is done on oracle table.
Is it possible to trigger a SAS program after every update or insert on Oracle table.
There's a few different ways to do this but a problem like this is an example of the saying "Just because you can, doesn't mean you should".
So sure, your trigger can be fired on update or insert and that can call a stored procedure in a package which can use the oracle host command to call an operating system command which can call SAS.
Here are some questions:
do you really want to install SAS on the same machine as your Oracle database?
do you really want every transaction that inserts or updates to have to wait until the host command completes? What if SAS is down? Do you want the transaction to complete or.....?
do you really want the account that runs the database to have privileges to start up or send information to other executables? Think security risks.
if an insert does one record the action is clear. What if an update affects a thousand records? What message do you want to send to SAS? One thousand update statements? One update statement?
There are better ways to do this but a complete answer needs more details from you as to the end goal and business logic involved. Some ways I have used include:
trigger inserts data into an Oracle advanced queue. At predetermined intervals take the changes off the queue and write them to a flat file. Write a file watcher to look for the files and send the info to SAS.
write a Java program to take the changes and ship them
use the APEX web service and expose the changes as a series of JSON or REST packets.

Generate upgrade script to ALTER TABLE based on CREATE TABLE statement in Oracle [duplicate]

This question already has answers here:
Automated Oracle Schema Migration Tool [closed]
(5 answers)
Closed 7 years ago.
Is it possible in Oracle to generate a bunch of ALTER TABLE statements based on existing table in schema plus CREATE TABLE statement with newer definition of that table?
Let's say I have a schema with some previous version of an application. I have an installation script for newest version of the application. The script creates all tables and sequences from scratch performing CREATE TABLE (and probably CREATE SEQUENCE) statements.
I'd like to update the schema to the newest version of the application without loosing any data (e.g. without performing DROP TABLE).
Is it possible with using of standard Oracle 11gR2 or third party components?
You can try CORT : www.cort.tech
https://github.com/cort-master/cort
It's free
You can create a procedure in PLSQL to:
create new table when it not exists in new DB
alter table when it exists, feeding it with ALL_TAB_COLUMNS

Oracle Find Table or View or MV References [duplicate]

This question already has an answer here:
Oracle query that will list of the database objects referenced by a view
(1 answer)
Closed 8 years ago.
Problem:
when I look at a table, or view or mv, I wonder where this table is being used within the database itself. it has the following possibilities:
update or manipulated through a package
update through a procedure
join or referenced with other tables, views or mvs
called by another database through a DB link
I Java, especially in IDEA like eclipse or netbeans, ctl+shift+g would give you all the
reference on a object.
how do we achieve this is Oracle.
You may try dba_dependencies (or all_dependecies depending on your privileges) for table references, or search the text field in dba_source for package details.

Oracle sql result to DBF file export

I would like to export data from a Oracle table into *.dbf file (like excel) through PL/SQL scripts. Are there any codes available?
There are a number of different ways to do this. The easiest way is to use an IDE like SQL Developer or TOAD, which offer this functionality.
If you want to call it from PL/SQL, then then are no built-in Oracle functions. However, it is relatively straightforward to build something using UTL_FILE which can write out value separated records. These can be picked up in Excel.
Note that the default separator - , (comma being the "C" in .CSV) - will cause problems if your exported data contains commas. So you will need to use the Data Import wizard rather than a right-click Open With ...
Incidentally, it is probably a bad idea to use the .dbf suffix. In an Oracle file system the presumed meaning is database file - i.e. part of the database's infrastructure. This is just a convention, but there is no point in needlessly confusing people. Perferred alternatives include .csv, .dmp or .exp.
edit
If your interest is just to export data for transferring to another Oracle database then you should look at using the Data Pump utility. This comes with an API so it can be used from PL/SQL. Alternatively we unload data through external tables declared with a DataPump driver.
You could also consider using the External Tables feature of Oracle. This essentially allows you to map a CSV file to a 'virtual' table and the you can insert into it (and therefore the file.)
Oracle External Tables Concept Guide

Resources