Sie sind auf Seite 1von 3

// PROGRAM NO.

1
// Create Database for your Class group containing information Name, Roll No., Branch of a
student.

SQL> create table TABLENAME(name varchar(20),rollno number(6,0),class


char(3),branch char(10));

Table created.

SQL> insert into TABLENAME values('&name','&rollno','&class','&branch');


Enter value for name: rohit
Enter value for rollno: 107040
Enter value for class: co3
Enter value for branch: computer
old 1: insert into TABLENAME values('&name','&rollno','&class','&branch')
new 1: insert into TABLENAME values('rohit','107040','co3','computer')

1 row created.

SQL> /
Enter value for name: shashikant
Enter value for rollno: 107458
Enter value for class: c3
Enter value for branch: civil
old 1: insert into TABLENAME values('&name','&rollno','&class','&branch')
new 1: insert into TABLENAME values('shashikant','107458','c3','civil')

1 row created.

SQL> /
Enter value for name: ankur
Enter value for rollno: 107124
Enter value for class: co3
Enter value for branch: computer
old 1: insert into TABLENAME values('&name','&rollno','&class','&branch')
new 1: insert into TABLENAME values('ankur','107124','co3','computer')

1 row created.

SQL> SELECT * FROM TABLENAME;

NAME ROLLNO CLA BRANCH


-------------------- ---------- --- ----------
rohit 107040 co3 computer
shashikant 107458 c3 civil
ankur 107124 co3 computer
SQL> UPDATE TABLENAME SET name='shyam' where name='rohit';

1 row updated.

SQL> select * from TABLENAME;

NAME ROLLNO CLA BRANCH


-------------------- ---------- --- ----------
shyam 107040 co3 computer
shashikant 107458 c3 civil
ankur 107124 co3 computer

SQL> DELETE FROM TABLENAME WHERE name='shyam';

1 row deleted.

SQL> /

0 row deleted.

SQL> INSERT INTO TABLENAME VALUES('ROHIT','107040','CO3','COMPUTER');

1 row created.

SQL> SELECT * FROM TABLENAME;

NAME ROLLNO CLA BRANCH


-------------------- ---------- --- ----------
shashikant 107458 c3 civil
ankur 107124 co3 computer
ROHIT 107040 CO3 COMPUTER

SQL> ALTER TABLE TABLENAME DROP COLUMN CLASS 2;


Table altered.

SQL> SELECT * FROM TABLENAME;

NAME ROLLNO BRANCH


-------------------- ---------- ----------
shashikant 107458 civil
ankur 107124 computer
ROHIT 107040 COMPUTER

SQL> ALTER TABLE TABLENAME ADD CLASS NUMBER(6,0);

Table altered.
SQL> SELECT * FROM TABLENAME;

NAME ROLLNO BRANCH CLASS


-------------------- ---------- ---------- ----------
shashikant 107458 civil
ankur 107124 computer
ROHIT 107040 COMPUTER

Das könnte Ihnen auch gefallen