DBMS LAB DAY 2

SQL> create table student(rollno number,name varchar2(20),aggr number(10,2),dob date);

Table created.

SQL> desc student;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ROLLNO                                             NUMBER
 NAME                                               VARCHAR2(20)
 AGGR                                               NUMBER(10,2)
 DOB                                                DATE

SQL> insert into student values(1,'aksay',95.8,'12-aug-12');

1 row created.

SQL> select * from student;

    ROLLNO NAME                       AGGR DOB                                 
---------- -------------------- ---------- ---------                            
         1 aksay                      95.8 12-AUG-12                           



SQL> insert into student(rollno,name,aggr,dob) values(2,'sruthi',98.7,'13-dec-97');

1 row created.

SQL> insert into student values (&rollno,'&name',&aggr,'&dob');
Enter value for rollno: 3
Enter value for name: venkat
Enter value for aggr: 78.9
Enter value for dob: 29-aug-84
old   1: insert into student values (&rollno,'&name',&aggr,'&dob')
new   1: insert into student values (3,'venkat',78.9,'29-aug-84')

1 row created.

SQL> /
Enter value for rollno: 4
Enter value for name: calvin
Enter value for aggr: 97
Enter value for dob: 12-jan-86
old   1: insert into student values (&rollno,'&name',&aggr,'&dob')
new   1: insert into student values (4,'calvin',97,'12-jan-86')

1 row created.



SQL> select * from student;

    ROLLNO NAME                       AGGR DOB                                 
---------- -------------------- ---------- ---------                           
         1 aksay                      95.8 12-AUG-12                           
         2 sruthi                     98.7 13-DEC-97                           
         3 venkat                     78.9 29-AUG-84                           
         4 calvin                       97 12-JAN-86                            

SQL> alter table student add address varchar2(10);

Table altered.

SQL> select * from student;

    ROLLNO NAME                       AGGR DOB       ADDRESS                   
---------- -------------------- ---------- --------- ----------                
         1 aksay                      95.8 12-AUG-12                           
         2 sruthi                     98.7 13-DEC-97                           
         3 venkat                     78.9 29-AUG-84                            
         4 calvin                       97 12-JAN-86                           

SQL> desc student;
 Name                                      Null?    Type
 --------------------------------- -------- ----------------------------
 ROLLNO                                             NUMBER
 NAME                                               VARCHAR2(20)
 AGGR                                               NUMBER(10,2)
 DOB                                                DATE
 ADDRESS                                            VARCHAR2(10)

SQL> alter table student modify name varchar2(25);

Table altered.

SQL> desc student;
 Name                                      Null?    Type
 ------------------------------- -------- ----------------------------
 ROLLNO                                             NUMBER
 NAME                                               VARCHAR2(25)
 AGGR                                               NUMBER(10,2)
 DOB                                                DATE
 ADDRESS                                            VARCHAR2(10)

SQL> alter table student modify name char(20);

Table altered.

SQL> alter table student rename  column aggr to percentage;

Table altered.



SQL> alter table student drop column dob;

Table altered.

SQL> select * from student;

    ROLLNO NAME                 PERCENTAGE ADDRESS                             
---------- -------------------- ---------- ----------                          
         1 aksay                      95.8                                      
         2 sruthi                     98.7                                     
         3 venkat                     78.9                                     
         4 calvin                       97                                      

SQL> rename student to enggstudent;

Table renamed.

SQL> select * from student;
select * from student
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from enggstudent;

    ROLLNO NAME                 PERCENTAGE ADDRESS                             
---------- -------------------- ---------- ----------                          
         1 aksay                      95.8                                     
         2 sruthi                     98.7                                      
         3 venkat                     78.9                                     
         4 calvin                       97                                     

SQL> truncate table enggstudent;

Table truncated.

SQL> select * from enggstudent;

no rows selected

SQL> drop table enggstudent;

Table dropped.

SQL> desc enggstudent;
ERROR:

ORA-04043: object enggstudent does not exist