Dbms Practicals
Dbms Practicals
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database SECOMP;
Query OK, 1 row affected (8.38 sec)
SELECT:
acpce@acpce-ThinkCentre-M70s: ~
Swapnil |
Praneet |
4 rows in set
Activities (J Terminal+ Feb14 11:45 e
ES +l acpce@acpce-ThinkCentre-M70s: ~
ne
| Harsh
| Praneet
| sahil
3 rows in set (0.00 sec)
| poctor_id
| DName varchar(30) | YES
| salary
+ +
3 rows in set (0.01 sec)
Database changed
mysql> A
>;
ERROR 1064 (42008): You have an error in your SQL syntax; check the manual that correspends to your MySQL server version for the right syntax
to use near 'A' at line 1
mysql> exit]
ALTER TABLE:
es Feb28 12:34 &
«yy Mm acpce@acpce-ThinkCentre-M70s: ~
Database changed
mysql> select * from Doctor;
select * from Doctor;
~C
mysql> select * from Doctor;
:
| 460008
| 260608
| 366608
| 560606
+
4 rows in set (0.00 sec)
C
| Doctor_id
| DName varchar(30) | YES
| salary
+
3 rows in set (0.01 sec)
ES +1 acpce@acpce-ThinkCentre-M70s: ~
| Doctor_id | NULL
| DName varchar(30) | YES | NULL
| Salary float | NULL
+= +
3 rows in set (0.01 sec)
“Y fl acpce@acpce-ThinkCentre-M70s: ~
| 400000
| 200000
| 300000
| 500000
+
4 rows in set (0.00 sec)
| 400000 [email protected]
| 200000 NULL
| 300000 [email protected]
| 560000
+
4 rows in set (0.00 sec)
+
| | 400000 harshi23ggmail.com
| | 200000 | NULL
| | 308000 [email protected]
| Priyanshu | 500000
+
4 rows in set (0.00 sec)
DELETE:
Activities &] Terminal v Feb28 12:34 e
“9 Il acpce@acpee-ThinkCentre-M70s: ~
mysql> 0
RENAME TABLE :
Activities Terminal Feb 28 12:3
acpce@acpce-ThinkCentre-M70s: ~
EMAIL
+ + -
LETS 00000 harshi123g@gmail
0 Swapnil NULL
0 Praneet 300000 [email protected] |
06 Priyanshu | 500000 [email protected] |
--- - --+
rows in set
DROP TABLE:
| | [email protected]
| Praneet 0ooe [email protected] |
| Priyanshu | 0OBO [email protected] |
Home + —-- +
3 rows in set (0.00 sec)
«
1 106 | Priyanshu | 500000 | [email protected] |
+ +n B = = o
4 in set (8.01 sec)
©
mysql> select * from Docto
-+- ---t +
|
“ +
B
101 | Harsh | 400000 | [email protected] |
104 | Praneet | 300000 [email protected] |
106 | Priyanshu | 500008 | [email protected] |
a +n --- --+
A
rows in set (0.01 sec)
DName 1
mysql> 0
Experiment no 4 : Integrity constraint
Result:
Number of Records: 2
faculty name Tacully gualification faculty subj laught facully experience collegeid
CHECK CONSTRAINT
| I |
| Khilan | |
| keushik | |
| Craiteli | 25 |
| Hardik | |
| Komal I |
| I |
OUTPUT:
| 1 | Ramesh | 35 | Ahmedabad
| 2000.20 |
| 2 | %xnilan | 25 | Deni | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.08 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8see.ee |
| 6 | Xomal | 22 | wp | 4500.00 |
| 7 | Meffy | 24 | Indore | 10000.80 |
Ee EE BE -
SQL > DELETE FROM CUSTOMERS VIEW MERC es ee BR a srs i
WHERE age = 22; | ID | name | AGE | ADDRESS | SALARY |
Bt mmm EE EEE +
OUTPUT:
The table will be deleted.
Aim:-Perform simple queries,string manipulation operations and aggregate
functions.
Code:-
show databases;
use employes;
desc employee;
output:-
| Resuttarid | HH Fite
| rRov
||a:
export: BY | Wrap Cell Content: Ia
Database
» |employee
information_schema
mysal
performance_schema
sys
| Result Grid | HH FterRovs: [|| Exports ER | Wrap Cel Content: TA
| Field Type Null Key Default Extra
» |ed int NO PRI LOO
ename varchar(25) YES Unknown
ejob varchar(25) YES UNI ro
esal varchar(25) YES z=
Word have am arroe Ln pour SOL synta heck the manual corresponds to your MySQL server wersios
¥or the right syntax to use rear “set{contact varchar(S@))' at line 1
student {contact warchar(58)1;
You have an error in your SJL syntaw; check the manual corresponds £0 your MESQL server versio
Eprtax to use rear (contact varchac(S3))" at lire 1
Ble student medify caluen contact warchar[587;
ery CK, © rows affected {8.82 soc)
Records: © Duplicates: B Warnings: &
88513756
Er el] 2o8di-82-15
JE I1491453 1000 -|E-15
input statement.
warchar (38),
wercha[#
Parthivi | Kalamboli
Sagar | Kalyan
Yash K. | Panvel
Parth | Khandeshwar
Pragati | Kharghar
+
in set (©.00
mysql> SAVEPOINT a;
Query OK, © rows affected (0.00 sec)
mysql> ROLLBACK TO a;
Query OK, © rows affected (0.00 sec)
Kalamboli
Kalyan
Panvel
——
(GELS ET
Nashik
mysql> COMMIT;
Query OK, 8 rows affected (0.01 sec)
mysql> ROLLBACK TO a;
ERROR 1365 (42000): SAVEPOINT a does not exist
mysql> select * from student;
+
-+
Parthivi Kalamboli |
Sagar Kalyan |
Yash K. Panvel |
Parth Khandeshwar |
Pragati Nashik |
Arya Nerul |
Vaishnavi | Ghansoli |
+
in set (9.60 sec)
mysql>
mysql> GRANT SELECT, INSERT ON *aids* TO 'dbms'@"localhost’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
mysql>
mysql> GRANT SELECT, INSERT ON aids TO 'dbms'@'localhost’;
ERROR 1146 (42502): Table 'aids.aids' doesn't exist
mysql> GRANT SELECT, INSERT ON dml.aids TO ‘dbms'@'localhost’;
ERROR 1146 (42502): Table 'dml.aids®' doesn't exist
mysql> GRANT SELECT, INSERT ON aids.dml TO ‘dbms'@'localhost’;
Query OK, © rows affected (0.91 sec)
mysql>
DBMS EXPERIMENT NO:9
Procedure:
1e use customer;
Emel
e l=
1e CREATE DEFIMER="root
ff localhost” PROCEDURE "get student info” (in age int)
.
2 BEGIN
get_student_info - Routing
1e use customer;
Built-In Function:
IE get_student_info - Routine
full _narme
p |Sagar Chavan
‘ash Kahste
Parth kKhatu
Atharva Thakur
User-Defined Function:
get_student_infa - Routine add five - Routine thl Update - Routing
Ld CREATE TRBLE students (Mame WRRCHAR(L2®), Math INT, English INT, Science INT, History INT);
om
tbl_Update
EEea [Rx
1 ® ATE DEFINER="
root @ localhost” FUNCTION "tbl_Updste™ (5_name Varchar(52), Ml INT, M2 INT, M3 INT, M4 INT) RETURNS int
2 DETERMINISTIC
3 iN
4 UPDATE students SET Math = ML, English = H2, Science = M3, History = M4
H WHERE Mame = 5_name; ‘
& RETURN 1;
7 END
add_five - Routine
Code:
<?php
$servername = "localhost”;
$username = "id20578810_root™;
$password = "5%>+8omPMmN4)a|~";
$mydb = "id20578810_student”;
/I Create connection
/I Check connection
if (1$conn) {
}
// Start transaction
mysqli_autocommit($conn, FALSE);
if (mysqli_query($conn, $sql)) {
sleep(5);
if (mysqli_query($conn, $sql2)) {
// Commit transaction
mysqli_commit($conn);
} else {
mysqli_rollback($conn);
1|DBMS-PR-12
echo "Transaction rolled back.”;
}
} else {
mysqli_rollback($conn);
}
// Release lock
/I Close connection
mysqli_close($conny;
>
Output:
2|DBMS-PR-12