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

SQL EXP1

The document describes a lab exercise on executing DDL commands to create and modify a table in an Oracle database. The lab involves: 1) Creating a STUDENT table with attributes regno, name, dob, marks and constraints, 2) Removing the marks attribute, 3) Changing the data type of regno, 4) Adding a phno attribute, and 5) Inserting 5 tuples and displaying the table. DDL commands like CREATE TABLE, ALTER TABLE, DROP COLUMN and INSERT are used to complete the tasks.

Uploaded by

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

SQL EXP1

The document describes a lab exercise on executing DDL commands to create and modify a table in an Oracle database. The lab involves: 1) Creating a STUDENT table with attributes regno, name, dob, marks and constraints, 2) Removing the marks attribute, 3) Changing the data type of regno, 4) Adding a phno attribute, and 5) Inserting 5 tuples and displaying the table. DDL commands like CREATE TABLE, ALTER TABLE, DROP COLUMN and INSERT are used to complete the tasks.

Uploaded by

Nishath Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DBMS LAB

Course Title: DBMS LAB Course code: CAC07P


1. Execute DDL Commands
Consider the table:STUDENT (regno number, name varchar2, dob date, marks number)
a) Create the above table with suitable constraints.
b) Remove the existing attribute marks from the table.
c) Change the data type of regno from number to varchar2.
d) Add a new attribute phno to the existing table.
e) Insert 5 tuples into the table.
f) Display the tuples in table
a) Create the above table with suitable constraints.
SQL>CREATE TABLE STUDENT(REGNO NUMBER, NAME VARCHAR2(10), DOB DATE,
MARKS NUMBER);
TABLE CREATED.
SQL>DESC STUDENT;

b) Remove the existing attribute marks from the table.


SQL> ALTER TABLE STUDENT DROP COLUMN MARKS;
TABLE ALTERED.
SQL>DESC STUDENT;

c) Change the data type of regno from number to varchar2.


SQL> ALTER TABLE STUDENT MODIFY REGNO VARCHAR2(20);
TABLE ALTERED.
SQL>DESC STUDENT;

d) Add a new attribute phno to the existing table.


SQL>ALTER TABLE STUDENT ADD PHNO NUMBER;
TABLE ALTERED.
SQL>DESC STUDENT;
e) Insert 5 tuples into the table.
SQL>INSERT INTO STUDENT VALUES(‘1001’,’ASHA’,’01-JAN-2001’,912345678);
1 ROW CREATED.
SQL>INSERT INTO STUDENT VALUES(‘1002’,’RANI’,’01-FEB-2002’,952731618);
1 ROW CREATED.
SQL>INSERT INTO STUDENT VALUES(‘1003’,’DEEPA’,’02-MAR-2003’,987654321);
1 ROW CREATED.
SQL>INSERT INTO STUDENT VALUES(‘1004’,’VANI’,’04-APR-2004’,965478123);
1 ROW CREATED.
SQL>INSERT INTO STUDENT VALUES(‘1005’,’DIVYA’,’05-MAY-2005’,987321456);
1 ROW CREATED.

f) Display the tuples in table


SQL>SELECT * FROM STUDENT;

You might also like