Dimas A Lasama

12Dec/101

select dbms_metadata.get_ddl

View script Create or Replace Create Table, CREATE OR REPLACE FORCE VIEW, PROCEDURE AND etc using SQLPLUS

Using TABLE for view script table,
Using View for View script view.

Try another by your self

SQL> set lines 125 pages 1000

SQL> set long 100000
SQL> select dbms_metadata.get_ddl('TABLE','REGIONS','HR') from dual;

DBMS_METADATA.GET_DDL('TABLE','REGIONS','HR')
--------------------------------------------------------------------------------

18Nov/10Off

Installation Oracle SqlDeveloper

Using sqldeveloper for Ubuntu.

Follow this step to install the Oracle sqldeveloper.

1. Download Open Jdk

sudo apt-get install openjdk-6-jre

2. Download Oracle SqlDeveloper

www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

Download for oracle

18Nov/10Off

Installation Oracle 10g on Ubuntu

Install Oracle 10G on Ubuntu is so Easy

1. Install the package
sudo apt-get install build-essential libaio1 rpm lesstif2-dev alien
2. Create user and group for  oracle installation :
* sudo groupadd oinstall
* sudo groupadd dba
* sudo groupadd nobody
*
sudo useradd -g oinstall -G dba,nobody -m oracle -s /bin/bash
11Nov/10Off

Flashback query using SCN

SQL> show user;
USER is “SCOTT”
1)  Here you must the know the SCN value to restore back the old data. The current
SCN can be found using:
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
3297508
You can store this value in a table for future reference.
11Nov/10Off

Flashback query using date

SQL> show user;
USER is "SCOTT"


1)  You have wrongly updated the salary of employee ALLEN using command:

SQL> update emp set sal=1800 where ename='ALLEN';

1 row updated.

SQL> commit;

Commit complete.

SQL> select ename, sal from emp where ename='ALLEN';

ENAME             SAL
---------- ----------
ALLEN            1800

2)  Now you have to restore it back to its old value which you do not know. Find
the old value using the flashback query as follows:

	SELECT ename, sal FROM emp
	AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '6' MINUTE)
        WHERE ename = 'ALLEN';

    This query will pick the old value of "sal" existing 6 minutes before.

SQL> /