Source Code converted from Oracle to Postgresql
scott_pgsql_employee.php
 scott_pgsql_employee.txt
Creating table

 

 

 

Script:

TABLE DEPT

-- Table: dept

-- DROP TABLE dept;

CREATE TABLE dept
(
deptno numeric(2,0) NOT NULL,
dname character varying(14),
loc character varying(13),
CONSTRAINT pk_dept PRIMARY KEY (deptno)
)
WITH (
OIDS=FALSE
);
ALTER TABLE dept
OWNER TO postgres;

TABLE emp

-- Table: emp

-- DROP TABLE emp;

CREATE TABLE emp
(
empno numeric(4,0) NOT NULL,
ename character varying(10),
job character varying(9),
mgr numeric(4,0),
hiredate date,
sal numeric(7,2),
comm numeric(7,2),
deptno numeric(2,0),
CONSTRAINT pk_emp PRIMARY KEY (empno),
CONSTRAINT fk_deptno FOREIGN KEY (deptno)
REFERENCES dept (deptno) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE emp
OWNER TO postgres;
 

TABLE bONUS:

-- Table: bonus

-- DROP TABLE bonus;

CREATE TABLE bonus
(
ename character varying(10),
job character varying(9),
sal numeric,
comm numeric
)
WITH (
OIDS=FALSE
);
ALTER TABLE bonus
OWNER TO postgres;
 

TABLE SALGRADE

-- Table: salgrade

-- DROP TABLE salgrade;

CREATE TABLE salgrade
(
grade numeric,
losal numeric,
hisal numeric
)
WITH (
OIDS=FALSE
);
ALTER TABLE salgrade
OWNER TO postgres;
 

 

Views :

Dept :

EMP

View : Table Salgrade

Testing a COMPLEX/Subquery

SELECT * FROM EMP
WHERE DEPTNO IN
(SELECT DEPTNO FROM DEPT
WHERE LOC = 'DALLAS');

 

Retrieving/Querying results using PHP