0% found this document useful (0 votes)
18 views6 pages

DBMS

The document outlines SQL commands for creating and populating two tables: 'dept' and 'emp'. It includes commands for inserting data into these tables, displaying the contents of the tables, and querying specific records. The final output shows the structure and data of both tables, including department and employee details.

Uploaded by

Sana Shyzu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

DBMS

The document outlines SQL commands for creating and populating two tables: 'dept' and 'emp'. It includes commands for inserting data into these tables, displaying the contents of the tables, and querying specific records. The final output shows the structure and data of both tables, including department and employee details.

Uploaded by

Sana Shyzu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SIMPLE QUERIES

SQL> show user


USER is "csmb667 7 "
SQL> Create table dept (deptno number (2,0), dname varchar2 (14), loc
varchar2 (13), constraint pk dept primary key (deptno) ):
Table created.

SQL> create table emp (


2 empno number (4,0),
3 ename varchar2 (10)
job varchar2 (9),
mgr number (4,0),
hiredate date,
sal number (7,2) ,
Comm number (7,2),
9 deptno number (2, 0),
10 constraint pk emp primary key (empno),
11 constraint fk deptno foreign key (deptno) references dept
(deptno )) ;
Table created.

SQL> Select *from tab:

TNAME

TABTYPE CLUSTERID

DE PT
TABLE

EMP
TABLE

SQL> set autocommit on;


sQL> insert into DEPT (DEPTNO, DNAME, LOC) values (10, 'ACCOUNI ING',
'NEW YORK') ;

1 row Created.

Commit complete.
SQL> insert into dept values (20, 'RESEARCH', 'DALLAS') ;
1 row created.

Commit complete.
sQL> insert into dept values (30, 'SALES, ' CHICAGO') ;
SQL> insert into emp values (7521, WARD', 'SALESMAN', 7698,
to date('22-2-1981', * dd-mm-yyyy'), 1250, 500, 30) :
1 row created.

Commit complete.
SQL> insert into emp values (7654, 'MARTIN', ' SALESMAN', 7698,
to_date ('28-9-1981', ' dd-mm-yyyy'), 1250, 1400, 30) ;
1 row created.

Commit complete.
SQL> insert into emp values (7844, TURNER' 'SALESMAN', 7698,
to date ('8-9-1981', ' dd-mm-yyyy'), 1500, 0, 30) ;
1 row Created.

Commit complete.
sQL> insert into emp values (7876, 'ADAMS, 'CLERK', 7788,
to date ('13-JUL-87', 'dd-mm-yyyy'), 1100, null, 20) :
1 row created.

Commit complete.
SQL> insert into emp values (7900, 'JAMES', 'CLERK', 7698, to date('3
12-1981', ' dd-mm-yyyy'), 950, null, 30);
1 row created.

Commit complete.
SQL> insert into emp values (7934, 'MILLER', 'CLERK ',
7782, to date ('23-1-1982,'dd-mm-yyyy'), 1300, null, 10) :
1 row created.

Commit complete.
SQL> select *from emp;
EMPNO ENAME JOB MGR HIRE DATE SAL
COMM

DEPTNO

7839 KING PRESIDENT 17-NOV-81 5000


10

7698 BLAKE MANAGER 7839 0l-MAY-81 2850


30

7782 CLARK MANAGER 7839 09-JUN-81 2450


10

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
Commit complete.
SQL> insert into dept values (40, 'OPERATIONS, BOSTON')
1 row Created.

Commit complete.
SQL> insert into emp values (7839, 'KING', PRESI DENT', null,
to date ('17-11-1981','dd-mm-yyyy'), 5000, null, 10):
1 roW Created,

Commit complete.
SQL> insert into emp values (7698, 'BLAKE', "
MANAGER', 7839,
to date ('1-5-1981', 'dd-mm-yyyy'), 2850, null, 30);
1 row Created.

Commit complete.
SQL> insert into emp values (7782, 'CLARK' , 'MANAGER', 7839,
to date ('9-6-1981' , 'dd-mm-yyyy' ), 2450, null, 10) ;
1 roW Created.

Commit complete.
SQL> insert into emp values (7566, 'JONES',
'MANAGER', 7839,
to date ('2-4-1981', ' dd-mm-yyyy'), 2975, null, 20);
1 rowW Created.

Commit complete.
SQL> insert into emp values (7788, SCOTT', 'ANALYST', 7566,
to date ('13-JUL-87 ', ' dd-mm-yyyy'),3000, null, 20) ;
1 row Created.

Commit complete.
SQL> insert into emp values (7902, 'FORD',
ANALYST', 7566,
to date ('3-12-1981 ','dd-mm-yyyy') 3000, null, 20) ;
1 roW Created.

Commit complete.
SQL> insert into emp values (7369, 'SMITH', 'CLERK', 7902,
to date ('17-12-1980",'dd-mm-yyyy'), 800, null, 20):
1 row Created.

Commit complete.
SQL> insert into emp values (7499, 'ALLEN' , 'SALESMAN' , 7698,
to date ('20-2-1981', 'dd-mm-yyyy'), 1600, 300, 30) :
1 rowW Created.

Commit complete.
DEPTNO

7566 JONES MANAGER 7839 02-APR-81 2975


20

7788 SCOTT ANALYST 7566 13-JUL-87 3000


20

7902 EORD ANALYST 7566 03-DEC-81 3000


20

EMPNO ENAME JOB MGR HIRE DATE SAL


COMM

DEPTN0

7369 SMITH CLERK 7902 17- DEC-80 800


20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600


300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250


500
30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM

DEPTNO

7654 MARTIN SALESMAN 7698 28-SEP-81 1250


1400
30

7844 TURNER SALESMAN 7698 08-SEP-81 1500

30

7876 ADAMS CLERK 7788 13-JUL-87 1100


20

EMPNO ENAME JOB MGR HIRE DATE SAL


COMM

DEPTNO
7900 JAMES CLERK 7698 03- DEC-81 950
30

7934 MILLER CLERK 7782 23- JAN-82 1300


10

14 rows selected.

SQL> select *from dept;


DEPTN0 DNAME LOC

10 ACCOUNTING NEW YORK


20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> Set linesize 180:;


SQL> select *from emp;

EMPNO ENAME JOB MGR HIREDATE SAL


COMM DE PTNO

7839 KING PRESI DENT 17-NOV-81 5000


10
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7782 CLARK MANAGER 7839 09-JUN-81 2450
10
7566 JONES MANAGER 7839 02-APR-81 2975
20
7788 SCOTT ANALYST 7566 13-JUL-87 3000
20
7902 FORD ANALYST 7566 03-DEC-81 3000
20
7369 SMITH CLERK 7902 17 - DEC-80 800
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600
300 30
7521 WARD SALESMAN 7698 22 - FEB-81 1250
500 30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250
1400 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500
0 30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM DE PTNO

7876 ADAMS CLERK 7788 13-JUL-87 1100


20
7900 JAMES CLERK 7698 03-DEC-81 950
30
7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> select *from emp where empno=7902 ;


EMPNO ENAME JOB MGR HIREDATE SAL
COMM DE PTNO

7902 FORD ANALYST 7566 03- DEC-81 3000


20

SQL> select *from dept where deptno=30;


DEPTNO DNAME LOC

30 SALES CHICAGO

You might also like