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

Assignment 1

The document contains SQL commands that create a table called stud with columns rollno, name, marks, city. Data is inserted and various SQL commands like select, update, delete are used to manipulate the data in the table. Indexes are created on name and rollno, name columns. The table is later renamed to stud1 and additional column class is added and dropped.

Uploaded by

swati khurpe
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Assignment 1

The document contains SQL commands that create a table called stud with columns rollno, name, marks, city. Data is inserted and various SQL commands like select, update, delete are used to manipulate the data in the table. Indexes are created on name and rollno, name columns. The table is later renamed to stud1 and additional column class is added and dropped.

Uploaded by

swati khurpe
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical Number 1

Name - Rushikesh Patil


ROll - 3233

SQL> connect system;


Enter password:
Connected.
SQL> create table stud(rollno int,name varchar(20),marks int ,city varchar(20));

Table created.

SQL> insert into stud values(1,'Nachiket',90,'Jalgaon');

1 row created.

SQL> insert into stud values(2,'riya',70,'pune');

1 row created.

SQL> insert into stud values(5,'siya',88,'Nashik');

1 row created.

SQL> select * from stud;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 Pune
5 siya 88 Nashik

SQL> insert into stud values(6,'om',60,'Nashik');

1 row created.

SQL> insert into stud values(7,'Sonal',76,'mumbai');

1 row created.

SQL> select * from stud;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 Nashik
7 Sonal 76 mumbai

SQL> delete from stud where NAME='Sonal';

1 row deleted.

SQL> select * from stud;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 Nashik

SQL> alter table stud rename to stud1;

Table altered.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 Nashik

SQL> update stud1 set city='nagar' where rollno=6;

1 row updated.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 nagar

SQL> insert into stud1 values(6,'Sonal',76,'mumbai');

1 row created.

SQL> delete form stud1 where name='sonal';


delete form stud1 where name='sonal'
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> delete from stud1 where name='sonal';

0 rows deleted.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
7 om 60 nagar
6 Sonal 76 mumbai

SQL> delete form stud1 where name='Sonal';


delete form stud1 where name='Sonal'
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> delete from stud1 where name='Sonal';

1 row deleted.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 nagar

SQL> alter table stud1 add class varchar(20);

Table altered.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- ------------------
1 Nachiket 90 Jalgaon

2 riya 70 pune

5 siya 88 Nashik

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
CLASS
--------------------
6 priti 60 nagar

SQL> alter table stud1 modify class int;

Table altered.

SQL>
SQL> alter table stud1 drop class int;
alter table stud1 drop class int
*
ERROR at line 1:
ORA-00905: missing keyword

SQL> alter table stud1 drop column class int;


alter table stud1 drop column class int
*
ERROR at line 1:
ORA-00933: SQL command not properly ended

SQL> alter table stud1 drop column class;

Table altered.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 nagar

SQL> create view s as select name,marks from stud1;

View created.

SQL> select * from s;

NAME MARKS
-------------------- ----------
Nachiket 90
riya 70
siya 88
om 60

SQL> drop view s;

View dropped.

SQL> create index s on stud1(name);

Index created.

SQL>

SQL> create index studind on stud1(rollno,name);

Index created.

SQL> show index from stud1;


SP2-0158: unknown SHOW option "index"
SP2-0158: unknown SHOW option "from"
SP2-0158: unknown SHOW option "stud1"
SQL> show indexs from stud1;
SP2-0158: unknown SHOW option "indexs"
SP2-0158: unknown SHOW option "from"
SP2-0158: unknown SHOW option "stud1"
SQL> show indexes from stud1;
SP2-0158: unknown SHOW option "indexes"
SP2-0158: unknown SHOW option "from"
SP2-0158: unknown SHOW option "stud1"
SQL> show indexes from stud1 where rollno=6;
SP2-0158: unknown SHOW option "indexes"
SP2-0158: unknown SHOW option "from"
SP2-0158: unknown SHOW option "stud1"
SP2-0158: unknown SHOW option "where"
SP2-0158: unknown SHOW option "rollno=6"
SQL> insert into stud1(rollno,name) values(10,'pooja');

1 row created.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 nagar
10 pooja

SQL> update stud1 set rollno=7 where name='pooja';

1 row updated.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 priti 60 nagar
7 pooja

SQL> select rollno,name from stud1 ;

ROLLNO NAME
---------- --------------------
1 Nachiket
2 riya
5 siya
6 om
7 pooja

SQL> delete from stud1 where rollno=7;

1 row deleted.

SQL> select * from stud1;

ROLLNO NAME MARKS CITY


---------- -------------------- ---------- --------------------
1 Nachiket 90 Jalgaon
2 riya 70 pune
5 siya 88 Nashik
6 om 60 nagar

You might also like