Oracle:Section1

From mi-linux
Revision as of 18:17, 23 February 2016 by Cm1958 (talk | contribs) (Created page with "Main Page >> Oracle and SQL >> Workbook >> Section 1 answers == Answers to Section 1 == <p style="color: red"> '''You should only look at ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Main Page >> Oracle and SQL >> Workbook >> Section 1 answers

Answers to Section 1

You should only look at the answers once you have attempted them yourself!

Exercise 1.1 Type in the SQL code to display the structure of the CUSTOMER table.

DESC CUSTOMER

The result should be similar to the following:

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CNO                                                NUMBER(4)
 ORDERDATE                                          DATE
 NAME                                               VARCHAR2(15)
 CITY                                               VARCHAR2(15)
 COUNTRY                                            VARCHAR2(15)
 PNO                                                NUMBER(4)
 DESCRIPTION                                        VARCHAR2(20)
 QTY                                                NUMBER(4)

Type in the following commands separately:

describe dept

Shows the structure of the dept table

select * from dept;

Shows the contents of the dept table (data)

select * from emp;

Shows the contents of the emp table (data)

describe salgrade

Shows the structure of the salgrade table

select * from salgrade;

Shows the contents of the salgrade table (data)


Exercise 1.2

Now try and retrieve the employee's name, hiredate and sal:

SELECT ENAME, HIREDATE, SAL
FROM EMP;

The results should be similar to:

ENAME HIREDATE SAL


--------- ----------

KING 17-NOV-81 5000 JONES 02-APR-81 2975 SCOTT 09-DEC-82 3000 ADAMS 12-JAN-83 1100 FORD 03-DEC-81 3000 SMITH 17-DEC-80 800 BLAKE 01-MAY-81 2850 ALLEN 20-FEB-81 1600 WARD 22-FEB-81 1250 MARTIN 28-SEP-81 1250 TURNER 08-SEP-81 1500 JAMES 03-DEC-81 950 CLARK 09-JUN-81 2450 MILLER 23-JAN-82 1300

14 rows selected.