0% found this document useful (0 votes)
18 views

Table Creation

oracle SQL

Uploaded by

ashutosh singh
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 views

Table Creation

oracle SQL

Uploaded by

ashutosh singh
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/ 3

TABLE CREATION

SQL> CREATE TABLE Student45(Sname Varchar(10),rollno varchar(3));

Table created.

ADD RECORDS

SQL> INSERT INTO Student45 VALUES('Ann','1');

1 row created.

SQL> INSERT INTO Student45 VALUES('Tom','2');

1 row created.

SQL> INSERT INTO Student45 VALUES('Sam','3');

1 row created.

SQL> INSERT INTO Student45 VALUES('Tim','4');

1 row created.

SQL> INSERT INTO Student45 VALUES('Rina','5');

1 row created.

DISPLAY RECORDS

(a) All records

SQL> SELECT * FROM Student45;

SNAME ROL

---------- -

Ann 1

Tom 2

Sam 3

Tim 4

Rina 5

2. See the data structure of the table

SQL> DESC Student45;

Name Null? Type

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

SNAME VARCHAR2(10)

ROLLNO VARCHAR2(3)
II Create a table employee35

SQL> CREATE TABLE Employee35(Empid Number(5),Empname varchar(15),City varchar(10),salary


number(15));

Table created.

ADD RECORDS

SQL> INSERT INTO Employee35 VALUES(12,'Anita','Delhi',30000);

1 row created.

SQL> INSERT INTO Employee35 VALUES(13,'Seema','Mumbai',45000);

1 row created.

SQL> INSERT INTO Employee35 VALUES(16,'Leena','Mumbai',49000);

1 row created.

SQL> INSERT INTO Employee35 VALUES(19,'Raj','Bangalore',90000);

1 row created.

SQL> INSERT INTO Employee35 VALUES(25,'Ram','Bangalore',1000000);

1 row created.

DISPLAY RECORDS

a. All records

SQL> SELECT * FROM Employee35;

EMPID EMPNAME CITY SALARY

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

12 Anita Delhi 30000

13 Seema Mumbai 45000

16 Leena Mumbai 49000

19 Raj Bangalore 90000

25 Ram Bangalore 1000000

b. Records of all residing in Mumbai

SQL> SELECT * FROM Employee35 WHERE City = 'Mumbai';

EMPID EMPNAME CITY SALARY

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

13 Seema Mumbai 45000


16 Leena Mumbai 49000

c. Display records of all employees drawing > 50000 salary

SQL> SELECT * FROM Employee35 WHERE Salary > 50000;

EMPID EMPNAME CITY SALARY

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

19 Raj Bangalore 90000

25 Ram Bangalore 1000000

d. Display empid, emp name

SQL> SELECT Empid,Empname FROM Employee35;

EMPID EMPNAME

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

12 Anita

13 Seema

16 Leena

19 Raj

25 Ram

e. Display records of all those residing in Delhi and Mumbai

SQL> SELECT * from employee35 where City in('Delhi','Mumbai');

EMPID EMPNAME CITY SALARY

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

12 Anita Delhi 30000

13 Seema Mumbai 45000

16 Leena Mumbai 49000

You might also like