Posts

Showing posts from January, 2015

Generate sql file from EXPDP/IMPDP

It’s straight forward to generate DDL SQL Script from any specific schema. However, it has nothing to do with expdp. expdp arvind/password schemas=hr directory=DPUMP dumpfile=HR_2014_08_13.dmp logfile=impsql_HR_2014_08_13.log while importing you need to specify .sql file name using impdp, it will generate DDL SQL Script for any specific schema.  [oracle@qpdbdev202 dpump]$ impdp arvind/password directory=DPUMP  dumpfile=HR_2014_08_13.dmp sqlfile=HR_2014_08_13.sql logfile=impsql_HR_2014_08_13.log

Create sample table and insert random data in database

if you are trying to do some testing and want to insert some random data into tables. Lets say table name is T1. CREATE TABLE T1 (  ID NUMBER , NAME VARCHAR2(20 BYTE) ) TABLESPACE USERS; Insert Data : Here is a simple plsql block to insert 1500 rows into a table with unique ID and random string of 20 characters. DECLARE   i NUMBER :=1; BEGIN   LOOP     i := i+1;     insert into T1 values(i,(SELECT DBMS_RANDOM.STRING('A', 20) FROM DUAL));     commit;     dbms_output.put_line (i);     EXIT   WHEN i >= 1500;   END LOOP; END; select count (*) from T1; -- result : 1500 rows -- Note : You can alter the insert statement in pl/sql block as you want. -- You can increase the data by increasing i value to what ever you desire. Example i >= 15000; -- You can also increase the sequence by altering i := i +2 etc.. STRING The  STRING  function returns a string of random characters of the specified length. T...