(
Column_namel data-type(data size/
limit)
constraints,
Column_name? data-type(data size/
limit),
Column_name3 data-type(data size/
limit)
%
For example
Create table student
(
Admno int(5) primary key,
First_Name varchar(15) not null,
LastName _varchar(15),
DOB date,
Fees decimal(9,2),
State varchar(10)
% 3
28. Describe. This command is used to view the
structure of the table (that is a column name,
data-type and constraints).
Syntax
Desc
or
describe
For example
Desc student;
29, Insert, This isa DML command used to insert/
add a new record at the end of the table,
Syntax ai
. Insert into
(, ,
_ name3>) VALUES (;
For example
Select * from the student where
admno=1101;
Projection: This way is used to show specific
attributes from the table(s).
Syntax
Select , set
= where
;
For example
Update student Set state = ‘Haryana’
where admno = 1101;
33. Alter. This DDL command is used to add/
modify/remove structure(column) of the
table.
Syntax
Alter table
add ;
For example .
Alter table student add gender char(1);
34. Delete. This DML command is used to
remove rows or record(s) from the table.
Syntax
Delete from
where
;
For example
Select admno, name, fees from
student where state="Delhi’;
Distinct: This clause is used to
fetch(retrieve) unique values(non-
duplicate) from the column of the table.
Syntax
Select distinct from
;
For example '
Select distinct state from student;
Order by: This clause is used to
arrange the records of the relation
either in ascending or descending order
Syntax
Select * from
order
by ;
For example
* Select * from student order by admno;
# by default ascending order (ASC)(e) [loving This clause is used to specify
a condition on grouped column.
Syntax
Select,sum from
group by
having
count(column name) >
;
umpl
Select state, sum(fees) from
student group by state having
count(state)>5;
# To display state wise total fees
having more than 5 records.
37. Between operator. This operator is used to
display the data between a specified range
of Numbers or Date.
Syntax
Select * from
where
between
and ;
Both and are
inclusive.
For example
+ select * from student where admno
between 1100 and 1199;
+ Select * from student where admno not
between 1100 and 1199;
38. In operator. This clause is used to fetch the
information from the table by providing one
or more values from the specified column.
‘Syntax .
Select , where in
name2> ,
();
Database Management-SQL 21
For example
» Select admno, name from student where
state in(‘Delhi’,’Haryana’);
+ Select admno, name from student where
state not in(‘Delhi’,’Haryana’);
39. Like operator. This clause is used to search
the data according to the given pattern and
for this we need to use the two wild card
characters.
* Percent symbol (%).Matches any string.
+ Underscore (_). Matching single
character.
Syntax
Select , from
where
like ;
For example
Select * from student where name like
“AM;
#name starts with “A”.
40. Constraints. Constraints are rules to restrict
the type of data to be entered in a table. It
will be helpful in maintaining the accuracy,
integrity and reliability of the data. Most
commonly used constraints are Primary Key,
Foreign Key, Not Null, Check, default etc.
41. Aggregate Functions.
+ Sum(): This function is used to get total
value of specified column.
For example
Select sum(fees) from the student:
Max(): This function is used to find the
maximum value of the specified column
For example
Select max(fees) from the student;20 Pagecher euitk® Computer Science (Python) 12
»
* Update. This DML command is used to
modify/edit data/record(s) of the table.
Syntax
Update
set where
;
For example
Update student Set state = ‘Haryana’
where admno = 1101;
Alter. This DDL command is used to add/
modify/remove structure(column) of the
table.
Syntax
Alter table
add ;
For example
Alter table student add gender char(1);
. Delete. This DML command is used to
Temove rows or record(s) from the table.
Syntax
Delete from
where
;
For example
Delete from student;
# removes all records from the table.
Delete from student where state=’Delhi’
# remove only delhi records.
. Drop. This DDL command is used to remove
the records along with its structure of the
table from the database.
Syntax
Drop table
;
For example
Drop table student;
Clause. The condition through which record(s)
can be filtered.
(a) Where: This clause is used to search a
rows/record(s).
Syntax
Select , “column
name2> from
where
;
For ts
Select admno, name, fees from
student where state=’Delhi’;
Distinct’ This clause is used to
fetch(retrieve) unique values(non-
duplicate) from the column of the table
Syntax,
Select distinct from
;
For example
Select distinct state from student;
Order by: This clause is used to
arrange the records of the relation
either in ascending or descending order.
Syntax
Select * from