DBMS_LAB_HIMANSHU_KAUSHIK_21CSE028-1
DBMS_LAB_HIMANSHU_KAUSHIK_21CSE028-1
PRACTICAL NO. 1
SYNTAX:- insert into table name (column name1, column name2) values
(value1,value2);
SQL> /
Enter the value for name : Bhupesh
Enter the value for designation : Security Incharge
Enter the value for shift : Morning
Enter the value for salary : 800000
Enter the value for address : B.garh
1 row created.
SQL> / (then do again and again if you want to enter some other
values)
Result:- SQL query successfully executed. However, the result set is
empty.
PRACTICAL NO. 2
Student
name rollno class address
Employee
name designation shift salary address
PRACTICAL NO. 3
SYNTAX :- Syntax for accessing selected columns and all rows from a table :-
select column1,column2,column3 from table name;
EXAMPLE 2:- Display name,rollno from Student.
SQL> select name, rollno from student;
PRACTICAL NO. 3
Student
name rollno
Aditya 5
Bhupesh 90
Aditya 5
Student
name rollno
Aditya 5
Bhupesh 90
Student
name rollno class
Aditya 5 cse
Bhupesh 90 B.S.C
Aditya 5 cse
Student
name
Aditya
Aditya
Student
name rollno class address
PRACTICAL NO.4
SYNTAX:- Syntax for Deletion of the specific rows from the table :-
Delete from table name where condition;
EXAMPLE:- Delete from the table Employee where address is B.garh.
SQL> DELETE from Employee Where address=’B.garh’;
PRACTICAL NO.4
AIM:- Exercise on Deletion of data from the table using different conditions.
PRACTICAL NO. 5
PRACTICAL NO. 5
PRACTICAL NO. 6
AVERAGE(AVG):- AVG is used for returning average value of ‘n’ record and
ignoring null values.
Syntax:- select avg(expr) from table name;
SQL> select avg(salary) “Average” from Employee;
ABS:- It returns the absolute value of ‘n’. The Scalar Functions use a
default table called “dual”.
Syntax :- ABS(n)
SQL> select abs(-15) “absolute” from employee;
POWER:- It returns the powered value or returns ‘m’ raise to ‘n’ power. ‘n’
must be an integer value.
Syntax :- Power(m,n)
SQL> select power(3,3) ”Power” from employee;
ROUND:- It returns the n rounded to ‘m’ places right to the decimal point. If
‘m’ is omitted, ‘n’ is rounded to ‘0’. ‘m’ can be negative to round off digits left to
the decimal point. ‘m’ must be an integer.
Syntax :- ROUND(n,m)
SQL> select round(7.16,1) from employee;
SQRT:- It returns the square root of ‘n’ . If n<0, Null, SQRT return a real
result.
SQL> select sqrt(25) “square_root” from employee;
String function :-
LPAD :- Returns ‘char1’ left padded to length ‘n’ with the sequence of
character in ‘char2’. ‘Char2’ default to blank.
Syntax :- LPAD(char1,n,char2)
SQL> select lpad(‘aditya’,10,‘*’);
PRACTICAL NO. 6
1) AVG(SALARY)
Average
4400000
2) MIN(SALARY)
Minimum Salary
1600000
3) MAX(SALARY)
Maximum Salary
16000000
4) SUM(SALARY)
Salary Sum
17600000
5) COUNT(NAME)
count(name)
6) COUNT(*)
count(*)
1) ABS(-15)
absolute
15
15
2) POWER(3,3)
power
27
27
3) ROUND(7.16,1)
round
7.2
7.2
4) SQRT(25)
square root
1) LOWER
lower(“name”)
aditya
bhupesh
2) UPPER
upper(“name”)
ADITYA
BHUPESH
3) INIT
init(“name”)
Aditya
Bhupesh
4) LPAD(‘Aditya’)
lpad(‘aditya’)
****Aditya
1) TO_CHAR
to_char
16000000
1600000
PRACTICAL NO. 7
The constraints enforced the rules to prevent the user to enter the invalid data
in the table.
PRIMARY KEY
1) Column level
Syntax :- column_name datatype(size) primary key;
At Column level,we can apply only one primary key on one column.
2) Table level
Syntax :- primary key(columnname1,columnname2…..columnname n);
1) Column level
Syntax :- columnname datatype(size) not null;
Example :- Create a table Employee2 and use Not Null Constraint at the
column level.
SQL> create table Aarti(name varchar(12)not null, rollno number(12));
UNIQUE Constraint
1) Column level
Syntax :- columnname datatype(size) unique;
2) Table level
Syntax :- unique(columnname,[columnname,- - - - - ]);
PRACTICAL NO. 7
PRIMARY KEY
Structure of the Employee2 using Primary constraint at column level and Table
level
SQL> describe Employee2;
Employee2 [-]
name[varchar(12)][not null]
rollno[varchar(12)]
NOT NULL Constraint
Structure of the Employee2 using Not Null constraint at column and Table level.
SQL> describe Employee2;
Employee2 [-]
name[varchar(12)][not null]
rollno[varchar(12)]
UNIQUE Constraint
Structure of the Employee2 using Unique at column level & Table level.
SQL> describe Employee2;
Employee2 [-]
name[varchar(12)][unique]
rollno[varchar(12)][unique]