SlideShare a Scribd company logo
create table dept(
deptno number(2,0),
dname varchar2(14),
loc varchar2(13),
constraint pk_dept primary key (deptno)
);
create table emp(
empno number(4,0),
ename varchar2(10),
job varchar2(9),
mgr number(4,0),
hiredate date,
sal number(7,2),
comm number(7,2),
deptno number(2,0),
constraint pk_emp primary key (empno),
constraint fk_deptno foreign key (deptno) references dept (deptno)
);
insert into DEPT (DEPTNO, DNAME, LOC)
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', 'BOSTON') ;
insert into emp
values(
7839, 'KING', 'PRESIDENT', null,
to_date('17-11-1981','dd-mm-yyyy'),
5000, null, 10
);
insert into emp
values(
7698, 'BLAKE', 'MANAGER', 7839,
to_date('1-5-1981','dd-mm-yyyy'),
2850, null, 30
);
insert into emp
values(
7782, 'CLARK', 'MANAGER', 7839,
to_date('9-6-1981','dd-mm-yyyy'),
2450, null, 10
);
insert into emp
values(
7566, 'JONES', 'MANAGER', 7839,
to_date('2-4-1981','dd-mm-yyyy'),
2975, null, 20
);
insert into emp
values(
7788, 'SCOTT', 'ANALYST', 7566,
to_date('13-JUL-87','dd-mm-rr') - 85,
3000, null, 20
);
insert into emp
values(
7902, 'FORD', 'ANALYST', 7566,
to_date('3-12-1981','dd-mm-yyyy'),
3000, null, 20
);
insert into emp
values(
7369, 'SMITH', 'CLERK', 7902,
to_date('17-12-1980','dd-mm-yyyy'),
800, null, 20
);
insert into emp
values(
7499, 'ALLEN', 'SALESMAN', 7698,
to_date('20-2-1981','dd-mm-yyyy'),
1600, 300, 30
);
insert into emp
values(
7521, 'WARD', 'SALESMAN', 7698,
to_date('22-2-1981','dd-mm-yyyy'),
1250, 500, 30
);
insert into emp
values(
7654, 'MARTIN', 'SALESMAN', 7698,
to_date('28-9-1981','dd-mm-yyyy'),
1250, 1400, 30
);
insert into emp
values(
7844, 'TURNER', 'SALESMAN', 7698,
to_date('8-9-1981','dd-mm-yyyy'),
1500, 0, 30
);
insert into emp
values(
7876, 'ADAMS', 'CLERK', 7788,
to_date('13-JUL-87', 'dd-mm-rr') - 51,
1100, null, 20
);
insert into emp
values(
7900, 'JAMES', 'CLERK', 7698,
to_date('3-12-1981','dd-mm-yyyy'),
950, null, 30
);
insert into emp
values(
7934, 'MILLER', 'CLERK', 7782,
to_date('23-1-1982','dd-mm-yyyy'),
1300, null, 10
);
select ename, dname, job, empno, hiredate, loc
from emp, dept
where emp.deptno = dept.deptno
order by ename;
CREATE VIEW empvu80
AS SELECT empno,ename,sal
FROM emp
WHERE deptno = 40;
CREATE OR REPLACE VIEW empvu20
AS SELECT *
FROM emp
WHERE deptno = 20
WITH CHECK OPTION CONSTRAINT empvu20_ck ;
CREATE OR REPLACE VIEW empvu10
(empno,ename,job)
AS SELECT empno,ename,job
FROM emp
WHERE deptno= 10
WITH READ ONLY ;
DROP VIEW empvu80;
CREATE SEQUENCE dept_deptid_seq
INCREMENT BY 10
START WITH 50
MAXVALUE 99
NOCACHE
NOCYCLE;
INSERT INTO dept(deptno,
dname,loc)
VALUES (dept_deptid_seq.NEXTVAL,
'Support','Bombay');
SELECT dept_deptid_seq.CURRVAL
FROM dual;
ALTER SEQUENCE dept_deptid_seq
INCREMENT BY 20
MAXVALUE999999
NOCACHE
NOCYCLE;
DROP SEQUENCEdept_deptid_seq;
CREATE INDEX emp_last_name_idx
ON emp(ename);
DROP INDEX emp_last_name_idx;
CREATE SYNONYM d_sum
FOR dept_sum_vu;

More Related Content

TXT
Mysql schema emp dept
DOCX
Array imp of list
PDF
Hashing enderecamento aberto bean - bean
PDF
Hashing endereçamento aberto - main
TXT
Data Structures : array operations in c program
DOC
Final ds record
DOCX
C program to implement linked list using array abstract data type
Mysql schema emp dept
Array imp of list
Hashing enderecamento aberto bean - bean
Hashing endereçamento aberto - main
Data Structures : array operations in c program
Final ds record
C program to implement linked list using array abstract data type

What's hot (12)

PPTX
Double linked list
DOCX
Circular queue
PPTX
CQL 实现
PPTX
C & Python Introduction
PDF
ES2015 New Features
PPTX
Merge sort
PDF
An Introduction to Tinkerpop
RTF
CLinkedList
TXT
New text document
DOCX
PDF
CS50 Lecture3
PPTX
ภาษาซี
Double linked list
Circular queue
CQL 实现
C & Python Introduction
ES2015 New Features
Merge sort
An Introduction to Tinkerpop
CLinkedList
New text document
CS50 Lecture3
ภาษาซี
Ad

Similar to Create view ans sequence (20)

PDF
ScottCreate_1.pdf
PDF
lab.123456789123456789123456789123456789
 
PDF
Tablas, Codigos Base De Datos Excelsa
PDF
Tablas, Codigos De Base De Datos
DOCX
When debugging the code, use Drop table statementsto drop pr.docx
KEY
Writeable ct es_pgcon_may_2011
DOCX
Milestone 1 FINAL
PDF
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
TXT
Procesos
PPTX
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
PDF
Sentencias básicas en oracle
DOCX
Creating Tablespaces and Tables in DB2BCIS 4620zArchit.docx
PDF
Writeable CTEs: The Next Big Thing
PDF
25 MARCH1 list, generator.pdf list generator
PDF
C program
DOCX
Identificacion De Las Llaves Foraneas
DOCX
include.docx
DOCX
STACK1.docx
PDF
My C proggram is having trouble in the switch in main. Also the a co.pdf
DOCX
1- Return the names- IDS- and average salary of the top 10 employees w.docx
ScottCreate_1.pdf
lab.123456789123456789123456789123456789
 
Tablas, Codigos Base De Datos Excelsa
Tablas, Codigos De Base De Datos
When debugging the code, use Drop table statementsto drop pr.docx
Writeable ct es_pgcon_may_2011
Milestone 1 FINAL
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
Procesos
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
Sentencias básicas en oracle
Creating Tablespaces and Tables in DB2BCIS 4620zArchit.docx
Writeable CTEs: The Next Big Thing
25 MARCH1 list, generator.pdf list generator
C program
Identificacion De Las Llaves Foraneas
include.docx
STACK1.docx
My C proggram is having trouble in the switch in main. Also the a co.pdf
1- Return the names- IDS- and average salary of the top 10 employees w.docx
Ad

Recently uploaded (20)

PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPT
introduction to datamining and warehousing
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PPTX
Artificial Intelligence
PDF
737-MAX_SRG.pdf student reference guides
PPT
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
PPTX
UNIT - 3 Total quality Management .pptx
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
introduction to high performance computing
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
introduction to datamining and warehousing
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
III.4.1.2_The_Space_Environment.p pdffdf
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
Abrasive, erosive and cavitation wear.pdf
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
86236642-Electric-Loco-Shed.pdf jfkduklg
Artificial Intelligence
737-MAX_SRG.pdf student reference guides
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
UNIT - 3 Total quality Management .pptx
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
introduction to high performance computing
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

Create view ans sequence

  • 1. create table dept( deptno number(2,0), dname varchar2(14), loc varchar2(13), constraint pk_dept primary key (deptno) ); create table emp( empno number(4,0), ename varchar2(10), job varchar2(9), mgr number(4,0), hiredate date, sal number(7,2), comm number(7,2), deptno number(2,0), constraint pk_emp primary key (empno), constraint fk_deptno foreign key (deptno) references dept (deptno) ); insert into DEPT (DEPTNO, DNAME, LOC) 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', 'BOSTON') ; insert into emp values( 7839, 'KING', 'PRESIDENT', null, to_date('17-11-1981','dd-mm-yyyy'), 5000, null, 10 ); insert into emp values( 7698, 'BLAKE', 'MANAGER', 7839, to_date('1-5-1981','dd-mm-yyyy'), 2850, null, 30 ); insert into emp values( 7782, 'CLARK', 'MANAGER', 7839, to_date('9-6-1981','dd-mm-yyyy'), 2450, null, 10 ); insert into emp values( 7566, 'JONES', 'MANAGER', 7839,
  • 2. to_date('2-4-1981','dd-mm-yyyy'), 2975, null, 20 ); insert into emp values( 7788, 'SCOTT', 'ANALYST', 7566, to_date('13-JUL-87','dd-mm-rr') - 85, 3000, null, 20 ); insert into emp values( 7902, 'FORD', 'ANALYST', 7566, to_date('3-12-1981','dd-mm-yyyy'), 3000, null, 20 ); insert into emp values( 7369, 'SMITH', 'CLERK', 7902, to_date('17-12-1980','dd-mm-yyyy'), 800, null, 20 ); insert into emp values( 7499, 'ALLEN', 'SALESMAN', 7698, to_date('20-2-1981','dd-mm-yyyy'), 1600, 300, 30 ); insert into emp values( 7521, 'WARD', 'SALESMAN', 7698, to_date('22-2-1981','dd-mm-yyyy'), 1250, 500, 30 ); insert into emp values( 7654, 'MARTIN', 'SALESMAN', 7698, to_date('28-9-1981','dd-mm-yyyy'), 1250, 1400, 30 ); insert into emp values( 7844, 'TURNER', 'SALESMAN', 7698, to_date('8-9-1981','dd-mm-yyyy'), 1500, 0, 30 ); insert into emp values( 7876, 'ADAMS', 'CLERK', 7788, to_date('13-JUL-87', 'dd-mm-rr') - 51,
  • 3. 1100, null, 20 ); insert into emp values( 7900, 'JAMES', 'CLERK', 7698, to_date('3-12-1981','dd-mm-yyyy'), 950, null, 30 ); insert into emp values( 7934, 'MILLER', 'CLERK', 7782, to_date('23-1-1982','dd-mm-yyyy'), 1300, null, 10 ); select ename, dname, job, empno, hiredate, loc from emp, dept where emp.deptno = dept.deptno order by ename; CREATE VIEW empvu80 AS SELECT empno,ename,sal FROM emp WHERE deptno = 40; CREATE OR REPLACE VIEW empvu20 AS SELECT * FROM emp WHERE deptno = 20 WITH CHECK OPTION CONSTRAINT empvu20_ck ; CREATE OR REPLACE VIEW empvu10 (empno,ename,job) AS SELECT empno,ename,job
  • 4. FROM emp WHERE deptno= 10 WITH READ ONLY ; DROP VIEW empvu80; CREATE SEQUENCE dept_deptid_seq INCREMENT BY 10 START WITH 50 MAXVALUE 99 NOCACHE NOCYCLE; INSERT INTO dept(deptno, dname,loc) VALUES (dept_deptid_seq.NEXTVAL, 'Support','Bombay'); SELECT dept_deptid_seq.CURRVAL FROM dual; ALTER SEQUENCE dept_deptid_seq INCREMENT BY 20 MAXVALUE999999 NOCACHE NOCYCLE; DROP SEQUENCEdept_deptid_seq;
  • 5. CREATE INDEX emp_last_name_idx ON emp(ename); DROP INDEX emp_last_name_idx; CREATE SYNONYM d_sum FOR dept_sum_vu;