Friday, May 30, 2008

Oracle - Creating Test Data

Here are the queries that I used to create the EMPLOYEE test data..

You need a tablespace to create tables in it. Either you can use you existing table space or create a new one like below..


create tablespace rameshdb
datafile 'rameshdb.dat' size 500k reuse
autoextend on next 500k maxsize UNLIMITED;


The following query creates user, ramesh.


create user ramesh
identified by ramesh
default tablespace rameshdb
quota UNLIMITED on rameshdb
temporary tablespace temp
quota 5m on system;


The following query grants all permissions to the user, ramesh.


grant all privileges to ramesh;


This is the query to create a table called EMPLOYEE which has been


create table ramesh.EMPLOYEE (
ID number(6) not null,
FIRST_NAME varchar2(256) not null,
LAST_NAME varchar2(256) null,
JOINED_DATE date null,
DEPT varchar2(256) null,
ROLE varchar2(256) null,
primary key (ID)
);


Here is the sql to insert some test data


INSERT INTO ramesh.EMPLOYEE
VALUES (1, 'Ramesh', 'Dara', to_date('2000/01/04', 'yyyy/mm/dd'),'Software','Developer');


Get back to Developer Digest

No comments: