You are on page 1of 3

Ex. No.

: 1
Date : DDL COMMANDS
Objective:
1. To learn DDL Commands and their constraints
2. To learn how to use DDL commands for the given prolem
!. To learn how to appl" constraints in the dataase tale.
Back ground / Pre requisite:
DDL statements are organi#ed in five group of statements.
o $chema %&ect 'anipulation. These statements allow "ou to create( alter( drop schema
o&ects )tales( views( *e"s+
o ,rivileges. These statements allow "ou to grant or revo*e privileges or rights and roles.
o -nal"sis. These statements allow "ou to anal"#e information aout "our tales( indexes
and clusters.
o -uditing. These statements allow "ou to initiate auditing options.
o Commenting. These statements allow "ou to manage comments.information in the data
dictionar".
SQL statements are divided into two major categories DDL(Data Defnition
Language) and DML(Data Manipulation Language). DDL allows you perform the asic
operation such as creating tales or views! altering tale! dropping tales or views.
DML allows you to insert! update! delete! and selecting rows from the tale in the
dataase.
Creating Table:-
Description
"he create tale command is used to create a tale in SQL. "he tale consists of
various felds that may e numer or characters.
Syntax:-
#reate tale $tale%name& (colunm' type! column type ()
Example:-
SQL&create tale sample (rollno numer('))! class varchar*(+)),
Creating View:-
Description
"he create view command is used to create a view in SQL. "he view consists of
columns that are specifed in the select statement.
Syntax:-
#reate view $view%name& as (select statement),
Example:-
SQL&create tale sample' as select - from sample,
Desc command:-
Description
"he command is used to view the columns in the tale or view! and their
corresponding data types.
Syntax:-
desc $tale%name& . $view%name&,
Example:-
SQL& desc sample,
Alter table command:-
Description
"his command is used either to add a column or modify the data type of an
e/isting column.
Syntax:-
0lter tale $tale%name& add (column type),
0lter tale $tale%name& modify (column type),
Example:-
SQL& alter tale sample add(year numer(+)),
SQL& alter tale sample modify(class char),
Drop command:-
Description
"his command is used to deletes the records and tale structure or view
structure from the dataase.
Syntax:-
Drop tale $tale%name&,
Drop view $view%name&,
Example:-
SQL& drop tale sample,
SQL& drop view sample',
,rocedure: )/" the student+
Test Case: )/" the student+
0eview 1uestions :
1. 2h" the insert command is faster than delete3
*. 2hat is the maximum si#e of the column in a single tale3
!. 2rite a $1L 4uer" to eliminate duplicate records in the result without using an" constraints.
5. 2hat is difference etween DELETE 6 T07NC-TE commands3

You might also like