SQL DB Lab Manual
SQL DB Lab Manual
MySQL DATABASE
1. What is MySQL?
MySQL is currently the most popular database management system software used
for managing the relational database.
3. MySQL TABLE
Table is a collection of data, organized in terms of rows and columns. In DBMS term, table is
known as relation and row as tuple.
Teacher
Result:-
Id Name Age sex marks
103 Alex 28 M 28
104 Abebech 23 F 45
Result:-
Id name age sex marks
102 Joseph 30 M 87
103 Alex 28 M 50
104 Abebech 23 F 45
104 Abebech 23 F 45
7. MySQL REPLACE
Syntax :-REPLACE [INTO] table_name(column_list)
VALUES(value_list);
Example:- REPLACE INTO students (id, sex)
VALUES(4,'Fimale');
8. MySQL SELECT
8.1. Syntax of SELECT FROM statement in
MySQL
1, SELECT * FROM Table_name;
COUNT(Id)
4
Example: SELECT TOP 4 Id, name, age, gender FROM student WHERE age>=18 ;
Result:- returns only four rows from total rows of table students.
Examle:-
SELECT marks, SUM (marks) AS "Total mark" FROM student GROUP BY marks;
Result: returns total marks of student on mark column orders.
Example:-
SELECT name, SUM(age) AS "Total age" FROM students GROUP BY emp_name;
12. Relationship
12.1. MySQL Primary Key
Syntax:
ON UPDATE CASCADE
);
('Joseph', 'Jinka'),
('Mary', 'Konso'),
('John', 'Arbaminch');
Syntax
Syntax
SELECT column_list
FROM Table1
ON join_condition;
UNION
15. INTERSECT
Syntax: SELECT (coloumn_names) from table1[WHERE condition] INTERSECT
SELECT (coloumn_names) from table2 [WHERE condition];
NOT INTERSECT(EXCEPT)
Syntax: SELECT (coloumn_names) from table1[WHERE condition] NOT INTERSECT
SELECT (coloumn_names) from table2 [WHERE condition];
16. MINUS
Syntax:
SELECT * FROM First_table
MINUS
SELECT * FROM Second_table;
Projection (𝝅):
Select Id, name, from student;