Sei sulla pagina 1di 7

EXPERIMENT -1

1. TITLE: Study of DDL commands.


2. OBJECTIVES: At the end of the course students will able:
1. Have a good understanding of how several fundamental algorithms
work, Particularly those concerned with creation and updating of tables.
2. Have a good understanding of the fundamental DBMS used in computer
Science
3. be able to understand various queries and their execution.
4. be able to design new database and modify existing ones for new
Applications and reason about the efficiency of the result
3.1 AIM:
To study the usage of various Data Manipulation Language commands
3.2 SUBJECT RELATED OUTCOMES

To be able to understand the requirement and uses of database in the real life
and how to create database structure practically using basic database concepts.
1. To be able to CREATE table in the database.
2. To be able to ALTER or MODIFY table.
3. To be able to DROP table from the Database.

4 . INPUT:
4.1 REQUIREMENTS
Requires computers with at least one database tool ORACLE, MSSQL, DB2 etc.

4.2THEORY

A data definition language or data description language (DDL) is syntax similar to a


computer programming language for defining data structures, especially database
schemas.

CREATE - to create objects in the database


ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces
allocated
for the records are removed
o COMMENT - add comments to the data dictionary
o RENAME - rename an object
o
o
o
o

5. PROCEDURE:

1. CREATE TABLE
2. ALTER TABLE
a. ADD
b. MODIFY
3. TRUNCATE TABLE
4. DROP TABLE

1. CREATE TABLE COMMAND


A CREATE statement in SQL creates an object inside of a relational
database management system (RDBMS).
SQL>create table student (rollno number(2),name varchar2(20),dept
varchar2(5),doj date);
Expected Output:
SQL> desc student;
Name

Null?

Type

----------------------------------------- ----------------------------------- ROLLNO


NUMBER(2)
NAME

VARCHAR2(20)

DEPT

VARCHAR2(5)

DOJ

DATE

2. ALTER TABLE COMMAND


An ALTER statement in SQL changes the properties of an object inside
of a relational database management system (RDBMS).
ADD COMMAND
SQL> alter table student add regno number(10);
Table altered.

M.A.M. SCHOOL OF ENG

SQL> desc student;


Name

Null?

Type

----------------------------------------- ----------------------------------- ROLLNO


NUMBER(2)

NAME

VARCHAR2(20)

DEPT

VARCHAR2(5)

DOJ

DATE

REGNO

NUMBER(10)

3. MODIFY COMMAND
SQL> alter table student modify ( name varchar2(25));
Table altered.
SQL> desc student;
Name

Null?

Type

----------------------------------------- ----------------------------------- ROLLNO


NUMBER(2)
NAME

VARCHAR2(25)

DEPT

VARCHAR2(5)

DOJ

DATE

REGNO

NUMBER(10)

4. TRUNCATE TABLE COMMAND


In SQL, the TRUNCATE TABLE statement is a Data Definition Language (DDL)
operation that marks the extents of a table for deallocation (empty for reuse). The
result of this operation quickly removes all data from a table, typically bypassing
a number of integrity enforcing mechanisms.
INSERTING DATA INTO TABLE:
SQL> insert into student values(1,'ajay','cse','15-aug-06',8082104001);
1 row created
SQL> insert into student values(1,'barathi',ece','20-july-06',8083104001);

1 row created
SQL> select * from student;
ROLLNO NAME

DEPT

DOJ

REGNO

---------- ------------------------- ----- --------- ---------------------------------1 ajay


1 barathi

cse

15-AUG-06 8082104001

ece

20-JUL-06 8083104001

SQL> truncate table student;


Table truncated.

SQL> select * from student;


no rows selected
SQL> desc student;
Name

Null?

Type

----------------------------------------- ----------------------------------- ROLLNO


NUMBER(2)
NAME

VARCHAR2(25)

DEPT

VARCHAR2(5)

DOJ

DATE

REGNO

NUMBER(10)

5. DROP TABLE COMMAND


To destroy an existing database, table, index, or
view. SQL> drop table student;
Table dropped.
SQL> desc student;

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

6. ASSESMENT:
Self
study
15%

Theory
Knowledge
20%

Practical
perform
20%

Report
presentation
10%

7. CONCLUSION:

Note: this has to be write each student individually.

Sample
Test/ Viva
Questions/
spot quizzes
20%

Professional
behavior
15%

Questions for Viva (for technical assessment):


1. What do you mean by DDL Command?
2. What are the different data types used in the SQL?
3. Write the Following Data Definition Language Statement with Example.
Create Table
Alter Table
Modify Table
Truncate
Table Drop
Table.
4. Write code to add a new column in a table.
5. Differentiate Procedure and Non Procedural Query Language.
8. Self-study References:
1. Books/ Journals: SQL, PL/SQL: The Programming Language Of Oracle
by
Ivan Bayroos
2. SQL Bible Paperback - UPC: 9780764525841 by Alex Kriegel Published
By
Wiley
3. SQL: The Complete Reference, 3rd Edition[Paperback]
James R. Groff (Author), Paul N. W einberg (Author), Andrew J. Oppel(Author)
Web-sites resources:
1. http://www.scribd.com
2. http://computerscience2ndyear.files.wordpress.com/2012/02/dbms_iv.pdf
3. http://en.wikipedia.org/wiki/Data_definition_language
4.
http://www.orafaq.com/faq/what_are_the_difference_between_ddl_dml_and_
dcl_commands
5. http://www.wctmgurgaon.com/data/lab_manual/dbms_file.pdf

Potrebbero piacerti anche