Sie sind auf Seite 1von 5

LAB -3

SQL*Plus: Release 10.1.0.2.0 - Production on Tue Nov 9 22:10:01 2010

Copyright (c) 1982, 2004, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> create table stu11(stu_id char(20), name char(8), dob date, sex char(1), class char(2), hcode

char(1), dcode char(3), mtest number(2));

Table created.

SQL> describe stu11;

Name Null? Type

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

STU_ID CHAR(20)

NAME CHAR(8)

DOB DATE

SEX CHAR(1)

CLASS CHAR(2)
HCODE CHAR(1)

DCODE CHAR(3)

MTEST NUMBER(2)

SQL> insert into stu11 values(01,'Gyan','15-oct-1986','M',10,'R',9,96);

1 row created.

SQL> insert into stu11 values(02,'Vikash','10-Jan-1985','M',9,'G',8,98);

1 row created.

SQL> insert into stu11 values(03,'Muku','12-Dec-1898','M',7,'Y',6,87);

1 row created

SQL> insert into stu11 values(04,'Rose','16-oct-1981','F',5,'B',1,90);

1 row created.

SQL> insert into stu11 values(5,'sita','12-Dec-1889','F',3,'V',1,90);

1 row created.
SQL> select *from stu11;

# List all students name.

STU_ID NAME DOB S CL H DCO MTEST

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

1 Gyan 15-OCT-86 M 10 R 9 96

2 Vikash 10-JAN-85 M 9 G 8 98

3 Muku 12-DEC-98 M 7 Y 6 87

4 Rose 16-OCT-81 F 5 B 1 90

5 sita 12-DEC-89 F 3 V 1 90

# List the name and hcode of class 3.

SQL> select name,hcode,class from stu11 where class=3;

NAME H CL

-------- - --

sita V3

SQL> select name,hcode,class from stu11 where class=3;

NAME H CL

-------- - --

sita V3
#List name and age of class 9 student.

SQL> select name, round((sysdate-dob)/365) as age from stu11 where class=9 and sex='M';

NAME AGE

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

Vikash 26

#List name and mtest scores .

SQL> select name,mtest from stu11;

NAME MTEST

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

Gyan 96

Vikash 98

Muku 87

Rose 90

sita 90

#List the name of student whose name start with “G”.

SQL> select name,class from stu11 where name like'G%';

NAME CL

-------- --

Gyan 10

#List the names and house code of student.

SQL> select name,class,hcode from stu11 where name like'V%'and hcode='G';


NAME CL H

-------- -- -

Vikash 9 G

#List the student whose mtest score is between 80 and 90

SQL> select name,mtest from stu11 where class=3 and mtest between 70 and 90;

NAME MTEST

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

sita 90

Das könnte Ihnen auch gefallen