0% found this document useful (0 votes)
23 views6 pages

Dbms Exp3a

The document discusses implementing DDL commands in SQL. It describes various DDL commands like CREATE, ALTER, DROP, TRUNCATE and provides examples to create a table, alter table structure by adding, modifying and dropping columns, insert records and truncate and drop the table. It also provides post lab questions about data dictionary, schema, data types and NULL value in SQL.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Dbms Exp3a

The document discusses implementing DDL commands in SQL. It describes various DDL commands like CREATE, ALTER, DROP, TRUNCATE and provides examples to create a table, alter table structure by adding, modifying and dropping columns, insert records and truncate and drop the table. It also provides post lab questions about data dictionary, schema, data types and NULL value in SQL.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Second Year Computer Engineering Database Management System

Name-Nishant Patil
SE-Computer (Div – B) Roll number : 9629
Experiment no. : 3(Part-1) Date:-31/01/23
Academic Term :Jan-April 2023
Aim : To implement data definition language (DDL) commands

Tool Used : MySql / PostgreSQL


Related Course outcome : At the end of the course, Students will be able to Use
SQL : Standard language of relational database
Rubrics for assessment of Experiment:
Indicator Poor Average Good
Timeline submitted on Submitted in same Submitted in
(2) time or early (2) week (1) next week (0)
Applies all Not able to enforce Tables created
DDL/DML/TCL few constraints or without
commands with not able to write constraints or
DDL/DML/TCL Commands(2)
all specified proper TCL Failed to
constraint commands (1) implement
successfully (2) transaction (0.5)
Able to apply Able to apply Able to solved
optimized appropriate few queries or
Applies Appropriate SQL /
SQL/PLSQL SQL/PLSQL query queries with
PLSQL (3)
query (3) and getting correct partially correct
output (2) output (1)
Knowledge Unable to
Unable to answer 1 Able to answer
● In depth knowledge of the answer 2
question (1) 2 questions (2)
topic(2) questions(0)

Assessment Marks :

Timeliness (2)
DDL/DML/TCL (2)
Applies Appropriate SQL /
PLSQL (3)
Knowledge (2)
Total (10)

Total : (Out of 10)

Teacher's Sign :
Second Year Computer Engineering Database Management System

EXPERIMENT 3 DDL Commands


Aim To implement DDL – Data definition language command
Tools MySql / PostgreSQL
Second Year Computer Engineering Database Management System

Theory SQL: It is structured query language, basically used to pass the query to retrieve
and manipulate the information from database
DDL: The Data Definition Language (DDL) is used to create the database (i.e.
tables, keys, relationships etc), maintain the structure of the database and
destroy databases and database objects.
Eg. Create, Drop, Alter, Describe, Truncate

1. CREATE statements: It is used to create the table.

CREATE TABLE table_name(columnName1 datatype(size), columnName2


datatype(size),………);

2. DROP statements: To destroy an existing database, table, index, or


view. If a table is dropped all records held within it are lost and cannot
be recovered.

DROP TABLE table_name;

3. ALTER statements: To modify an existing database object.


Adding new columns:

Alter table table_name Add(New_columnName1 datatype(size),


New_columnName2 datatype(size),………);

Dropping a columns from a table :

Alter table table_name DROP column columnName:

Modifying Existing columns:

Alter table table_name Modify (columnName1 Newdatatype(Newsize));

4. Describe statements: To describe the structure (column and data


types) of an existing database, table, index, or view.

DESC table_name;

5. Truncate statements: To destroy the data in an existing database,


table, index, or view. If a table is truncated all records held within it are
lost and cannot be recovered but the table structure is maintained.

TRUNCATE TABLE table_name;


Second Year Computer Engineering Database Management System

Procedure 1. Write a query to create a table employee with empno, ename,


designation, and salary. Emp (empno number (4), ename
varchar2 (10), designation varchar2 (10), salary number (8,2));

code:-
create table Employee_01(empno numeric(4), ename
varchar(10),designation varchar(10),salary numeric(8,2));
output:-

2. Write a Query to Alter the column empno number (4) to empno


number (6).

code:-
alter table Employee_01 alter column empno set data type
numeric(6);
output:-

3. Write a Query to Alter the table employee with multiple


columns (empno, ename.)
Code:-alter table Employee_01 alter column empno set data
type numeric(6);
alter table Employee_01 alter column empname set data type
varchar(15);
ouput:-

4. Write a query to add a new column in to employee as


qualification varchar(6)
code :-
alter table Employee_01 add column qualification varchar(6);
output-

5. Write a query to add multiple columns in to employee dob date


, doj date
code:-
alter table Employee_01 add column dob date , add column doj
date;
Second Year Computer Engineering Database Management System

output:-

6. Write a query to drop a column ‘doj’ from an existing table


employee
code:-
ALTER TABLE Employee_01 DROP COLUMN doj;
output:-

7. Write a query to drop multiple columns ‘dob’ and ‘qualification’


from employee
code:-alter table Employee_01
drop column dob,
drop column qualification;
output:-

8. Insert some records in table


code:-
insert into Employee_01values(001,'Adi','coder',100000);
insert into Employee_01 values (002,'ria','designer',200000);
insert into Employee_01 values (003,'ale','developer',10000);

output:-

9. Truncate table EMP


code:-
TRUNCATE TABLE Employee_01;
Output:-

10. Drop table EMP


code:-
Drop table Employee_01;
Output:-
Table is deleted
Second Year Computer Engineering Database Management System

Post Lab 1. What is Data Dictionary?


Questions: 2. What is Schema?
3. What are different data types in SQL?
4. Write the effect of NULL

************

You might also like