DB Lab 2
DB Lab 2
Functions
Functions — String, Numeric, User-Defined, Stored
Aggregate Functions — SUM, AVG, MAX, MIN , COUNT, DISTINCT
SQL Is standard Language For Storing, Manipulating & Retrieving Data in DataBase.
➢ INSERT INTO INSERT INTO table_name( column1, column2....columnN) VALUES ( value1, value2....valueN);
TASKS
1 Database and Table – Create & Insert.
2 Tables – Show, Rename & Truncate.
3 Row & Column – Select, Add, Delete(Drop), Alter and Update.
4 Misc – Distinct & Alias Name, Count, AVG, SUM.
5 Apply Specific Tasks – we will see some examples
6 Sorting – Order by (Asc & Desc), Group by.
7 Wild Card Cxs – Like %
8 Condition/Operators - (And, Or, Between)
9 Constraints – (Default, Unique, PK, Fk, Null & Check)
10 Bodmas Rule , Control Flow (if)
11 Table with PK and Fk
12 Join & Union
13 Miscellaneous
14 Relationship
15 Final Project
Table
1. Create Table Employee (
2. Insert Into Employee (
3. Select * From Employee;
4. Describe a Table Describe
(Field, Datatype and Constraint)
5. Describe Row / Column
1
Select a Column
Select a Row
2
1. Select * from employee where EmpID ='3’;
2. update employee set Salary ='36.254’
where EmpName = 'Danilo ayzak';
4 8
“ Employee_X ” “ Employee_Y ”
Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the
table. If there is any violation between the constraint and the data action, the action is aborted.
Constraints can be column level or table level. Column level constraints apply to a column, and table level constraints apply to the
whole table.
• PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table
• FOREIGN KEY - Prevents actions that would destroy links between tables
• CREATE INDEX - Used to create and retrieve data from the database very quickly
TASKS
1 Join and Union
2 View, Index
3 Normalization
4 Relationship
5
6
|ORDERED BY |
(Asc)
| GROUP BY |
7
3| /*..... UNION ....*/ Database Name - SCHOOL
ORDERED BY |
(Desc) CS SECE
HAVING |
THANK YOU!!
DBMS Lab Cheat sheet by Yohannes R.