Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Sunday, 14 February 2016

Table Creation With Constraint : CUSTMER_DTL

TABLE NAME : CUSTOMER_DTL

create table customer_dtl
(
cust_no varchar2(6) references customer_mst,
bill_mon varchar2(3),
prev_read number(5),
curr_read number(5),
unit_price number(5,2) check(unit_price>0),
due_date date);

insert into customer_dtl values('ANA001','NOV',1234,2545,5.50,'26-DEC-05');
insert into customer_dtl values('VVN001','DEC',256,365,5.50,'20-JAN-06');
insert into customer_dtl values('ANA002','NOV',245,578,5.50,'26-DEC-05');
insert into customer_dtl values('BAK001','DEC',45,145,5.50,'20-JAN-06');
insert into customer_dtl values('VVN002','DEC',254,545,5.50,'20-JAN-06');
insert into customer_dtl values('ANA003','NOV',2255,2365,5.50,'26-DEC-05');

Table Creation With Constraints in Oracle :EMP Table

FOR SYBCA , MCA , Msc IT Students

TABLE NAME : EMP

create table emp
(
empno number(4) primary key,
ename varchar2(10),
job varchar2(9),
mg number(4),
hiredate date,
sal number(7,2),
comm number(7,2),
deptno number(2) references dept(deptno)
);

insert into emp values(7369,'smith','clerk',7902,'17-dec-80',800,0,20);
insert into emp values(7499,'allen','salesman',7698,'20-feb-81',1600,300,30);
insert into emp values(7521,'ward','salesman',7698,'22-feb-81',1250,500,30);
insert into emp values(7566,'jones','manager',7839,'02-apr-81',2975,0,20);
insert into emp values(7654,'martin','salesman',7698,'28-sep-81',1250,0,30);
insert into emp values(7698,'blake','manager',7839,'01-may-81',2850,0,30);
insert into emp values(7782,'clark','manager',7839,'09-jun-81',2450,0,10);
insert into emp values(7788,'scott','analyst',7566,'09-dec-81',3000,0,20);
insert into emp values(7839,'king','president',,'17-nov-81',5000,0,10);
insert into emp values(7844,'turner','salemsman',7698,'08-sep-81',1500,0,30);
insert into emp values(7876,'adams','clerk',7788,'12-jan-83',1100,0,20);
insert into emp values(7900,'james','clerk',7698,'03-dec-81',950,0,30);
insert into emp values(7902,'ford','analyst',7566,'03-dec-81',3000,0,20);
insert into emp values(7934,'miller','clerk',7782,'23-jan-82',1300,0,10);

Table Creation With Constraints in Oracle : DEPT Table

TABLE NAME : DEPT

create table dept
(
deptno number(2) primary key,
dname varchar2(14),
loc varchar2(13));

insert into dept values(10,'accounting','new york');
insert into dept values(20,'research','dallas');
insert into dept values(30,'sales','chicago');
insert into dept values(40,'operations','bostan');