SlideShare a Scribd company logo
THE UNIVERSITY OF
LARKANA
Assignment of DBMS
Database
A database is a collection of information that is organized so it can be easily accessed, managed, and updated. Think of it as a
digital storage system where you can keep data, such as names, numbers, or records, and quickly find or change them when
needed.
For example, a database might store all the contact details for people in a company or all the products in a store
SQL
SQL (Structured Query Language) is a programming language used to manage and manipulate databases, specifically relational
databases. It allows users to create, read, update, and delete data stored in tables. SQL is the standard language for interacting
with most relational database systems.
Key Functions of SQL:
• Create: Make databases and tables.
• Read: Retrieve data.
• Update: Modify existing data.
• Delete: Remove data.
database in my squel assignment for students.pdf
Types of SQL Commands:
1. Data Definition Language (DDL)
o CREATE: Creates new database objects (e.g., tables). o ALTER: Modifies existing database structures. o
DROP: Deletes database objects.
o TRUNCATE: Removes all records from a table but keeps the structure.
2. Data Manipulation Language (DML)
o SELECT: Retrieves data from the database. o INSERT: Adds new records into a table.
o UPDATE: Modifies existing records in a table. o DELETE: Removes records from a table.
3. Data Control Language (DCL)
o GRANT: Gives users access to the database. o REVOKE: Removes users' access rights.
4. Transaction Control Language (TCL)
o COMMIT: Saves all changes made in the transaction. o ROLLBACK: Reverts changes if something goes
wrong.
o SAVEPOINT: Sets a point within a transaction to which you can later roll back.
5. Data Query Language (DQL)
o SELECT: Used to query and fetch data from the database.
1. CREATE DATABASE
o Definition: Creates a new database called student_info.
2. USE DATABASE
o Definition: Selects the student_info database to work within it.
3. CREATE TABLE
o Definition: Creates a table named student with specified columns such as id, name, age, batch, etc.
4. INSERT INTO
o Definition: Inserts records into the student table.
5. SELECT
o Definition: Retrieves data from the student table. The asterisk (*) selects all columns, while specific
column names like city, name, and age select only those fields.
6. DISTINCT
o Definition: Retrieves unique values from the specified column, avoiding duplicates
7. WHERE
o Definition: Filters the results based on specified conditions
8. Arithmetic Operators in WHERE
o Definition: Uses arithmetic operations within the WHERE clause.
9. Comparison Operators in WHERE
o Definition: Compares values using operators like != (not equal) and >= (greater than or equal).
10. Logical Operators (AND)
o Definition: Retrieves rows that satisfy both conditions.
11. Logical Operators (OR)
o Definition: Retrieves rows that satisfy either of the conditions.
database in my squel assignment for students.pdf
Definition
12. BETWEEN
o : Selects rows where a column's value falls within a
specified range.
13. IN
o Definition: Checks if a value exists within a specified set of
values.
Definition
14. NOT IN
o : Selects rows where a value is not part of the specified set.
Definition
15. LIMIT
Definition: Limits the number of rows returned by the query.
16. ORDER BY
o : Sorts the result set by the specified column (ascending or
descending).
Definition
17. COUNT (Aggregate Function)
o Definition: Returns the number of rows that match a
specified condition.
18. MAX (Aggregate Function)
o Definition: Returns the maximum value of the specified
column.
19. MIN (Aggregate Function)
o Definition: Returns the minimum value of the specified
column.
20. AVG (Aggregate Function)
o Definition: Returns the average value of a numeric column.
21. SUM (Aggregate Function)
o Definition: Returns the total sum of a numeric column.
22. GROUP BY
o Definition: Groups rows with the same values into
summary rows.
23. HAVING
o Definition: Filters rows after the GROUP BY using aggregate
conditions.
24. UPDATE
o Definition: Updates existing records in a table.
25. DELETE
o Definition: Deletes records from the table based on the
condition.
26. ALTER TABLE
o Definition: Modifies the structure of an existing table
(adding, renaming, modifying, or removing columns).
database in my squel assignment for students.pdf
database in my squel assignment for students.pdf
27. TRUNCATE
o Definition: Removes all rows from a table without deleting
the table itself.
28. VIEW
o Definition: Creates a virtual table based on the result of a
SELECT query.
29. AS (Alias)
o Definition: Provides an alias to column names.
30. LIKE
o Definition: Retrieves rows where a column matches a
specified pattern.
Joins
Create Database
Creates a new database named joins.
Use Database
Selects the joins database for subsequent queries.
Create Table – std_table
Creates a std_table table with columns for student ID, name, and city.
Create Table – sub_table
Creates a sub_table table with columns for student ID and subject name.
Insert Data into std_table
Inserts student records into the std_table table. Insert
Data into sub_table
Inserts subject records into the sub_table table.
Select all from std_table
Retrieves all records from the std_table table.
Select all from sub_table
Retrieves all records from the sub_table table.
Inner Join std_table and sub_table
Returns matching records from both student and sub where std_id is the same
in both tables.
Left Join std_table and sub_table
Returns all records from the std_table table and matching records from
sub_table (if any).
Right Join std_table and sub_table
Returns all records from the sub_table table and matching records from
std_table (if any)
Cross Join std_table and sub_table
Returns the Cartesian product of the std_table and sub_table tables (all
combinations).
ER DIAGRAM
Create Database
Definition: This query creates a new database named university_info.
Select Database
Definition: This query selects the university_info database for use.
Create Faculty Table
Definition: Creates the Faculty table with columns fac_id and
faculty_name.
Create School Table
Definition: Creates the School table linked to the Faculty table via fac_id.
Create Program Table
Definition: Creates the Program table linked to the School table via
scho_id.
Create Courses Table
Definition: Creates the Courses table linked to the Program table via
pro_id.
Create Lecturers Table
Definition: Creates the Lecturers table linked to the School table via
scho_id.
Create Course_Lecturer Table
Definition: Creates the Course_Lecturer table to establish a many-
tomany relationship between Courses and Lecturers.
Create Students Table
Definition: Creates the Students table linked to the Program table via
pro_id.
Create Enrollments Table
Definition: Creates the Enrollments table to link students to courses.
Insert Data into Faculty Table
Definition: Inserts faculty records into the Faculty table.
Insert Data into School Table
Definition: Inserts school records into the School table, associating them with
faculties.
Insert Data into Program Table
Definition: Inserts program records into the Program table, associating them with
schools.
Insert Data into Courses Table
Definition: Inserts course records into the Courses table, linking them to programs.
Insert Data into Lecturers Table
Definition: Inserts lecturer records into the Lecturers table, associating them
with schools.
Insert Data into Course_Lecturer Table
Definition: Links courses with lecturers in the Course_Lecturer table.
Insert Data into Students Table
Definition: Inserts student records into the Students table, linking them to
programs.
Insert Data into Enrollments Table
Definition: Links students to courses in the Enrollments table.
DIAGRAM
DCL
CREATE DATABASE tcl;
Creates a new database named tcl.
USE tcl;
Selects the tcl database for future operations.
CREATE TABLE std_info(...);
Creates the std_info table with columns ID, NAME, AGE, and BATCH.
INSERT INTO std_info ...;
Inserts data into the std_info table.
SELECT * FROM std_info;
Retrieves all rows and columns from the std_info table.
database in my squel assignment for students.pdf
CREATE USER 'ali'@'localhost' IDENTIFIED BY 'ali1';
Creates a new user ali with password ali1. GRANT
SELECT ON tcl.std_info TO 'ali'@'localhost';
Grants ali permission to read data from std_info.
REVOKE INSERT ON tcl.std_info FROM 'ahmed'@'localhost';
Removes the INSERT permission from ahmed.
FLUSH PRIVILEGES;
Applies privilege changes.
SELECT User, Host FROM mysql.user ...;
Lists users ali, ahmed, and kabeer from the MySQL server.
SHOW GRANTS FOR 'ali'@'localhost';
Displays the privileges granted to ali.
TCL
CREATE TABLE
Definition: Creates a new table with specified columns.
SELECT @@autocommit
Definition: Checks the autocommit mode status.
SET autocommit = 0
Definition: Disables autocommit mode so transactions must be manually
committed.
START TRANSACTION
Definition: Begins a new transaction.
INSERT INTO
Definition: Inserts new data into a table.
SELECT * FROM
Definition: Retrieves all data from a table.
ROLLBACK
Definition: Undoes all changes made in the current transaction.
COMMIT
Definition: Permanently saves all changes made in the current transaction.
UPDATE
Definition: Modifies existing data in a table.
SAVEPOINT
Definition: Creates a checkpoint in a transaction, allowing rollback to this
point.
ROLLBACK TO SAVEPOINT
Definition: Rolls back changes to a specific savepoint without affecting earlier
changes.
Ad

More Related Content

Similar to database in my squel assignment for students.pdf (20)

Lab
LabLab
Lab
neelam_rawat
 
Chapter8 my sql revision tour
Chapter8 my sql revision tourChapter8 my sql revision tour
Chapter8 my sql revision tour
KV(AFS) Utarlai, Barmer (Rajasthan)
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
Les09
Les09Les09
Les09
Sudharsan S
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
NETsolutions Asia: NSA – Thailand, Sripatum University: SPU
 
Les09
Les09Les09
Les09
Vijay Kumar
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
HudaRaghibKadhim
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdf
KeerthanaP37
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
 
Les11
Les11Les11
Les11
Sudharsan S
 
PPT
PPTPPT
PPT
webhostingguy
 
Fundamentals of Database management system Lab Manual.pptx
Fundamentals of Database management system Lab Manual.pptxFundamentals of Database management system Lab Manual.pptx
Fundamentals of Database management system Lab Manual.pptx
Getnet Tigabie Askale -(GM)
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
Sherif Gad
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
SiddhantBhardwaj26
 
mysql.ppt
mysql.pptmysql.ppt
mysql.ppt
nawaz65
 
ADBMS Unit-II c
ADBMS Unit-II cADBMS Unit-II c
ADBMS Unit-II c
SSN College of Engineering, Kalavakkam
 
Dbms sql-final
Dbms  sql-finalDbms  sql-final
Dbms sql-final
NV Chandra Sekhar Nittala
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
Avinash database
Avinash databaseAvinash database
Avinash database
avibmas
 

Recently uploaded (20)

Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdfTOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
NhiV747372
 
L1_Slides_Foundational Concepts_508.pptx
L1_Slides_Foundational Concepts_508.pptxL1_Slides_Foundational Concepts_508.pptx
L1_Slides_Foundational Concepts_508.pptx
38NoopurPatel
 
problem solving.presentation slideshow bsc nursing
problem solving.presentation slideshow bsc nursingproblem solving.presentation slideshow bsc nursing
problem solving.presentation slideshow bsc nursing
vishnudathas123
 
Automated Melanoma Detection via Image Processing.pptx
Automated Melanoma Detection via Image Processing.pptxAutomated Melanoma Detection via Image Processing.pptx
Automated Melanoma Detection via Image Processing.pptx
handrymaharjan23
 
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
Taqyea
 
Process Mining Machine Recoveries to Reduce Downtime
Process Mining Machine Recoveries to Reduce DowntimeProcess Mining Machine Recoveries to Reduce Downtime
Process Mining Machine Recoveries to Reduce Downtime
Process mining Evangelist
 
Sets theories and applications that can used to imporve knowledge
Sets theories and applications that can used to imporve knowledgeSets theories and applications that can used to imporve knowledge
Sets theories and applications that can used to imporve knowledge
saumyasl2020
 
national income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptxnational income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptx
j2492618
 
AWS RDS Presentation to make concepts easy.pptx
AWS RDS Presentation to make concepts easy.pptxAWS RDS Presentation to make concepts easy.pptx
AWS RDS Presentation to make concepts easy.pptx
bharatkumarbhojwani
 
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
bastakwyry
 
How to Set Up Process Mining in a Decentralized Organization?
How to Set Up Process Mining in a Decentralized Organization?How to Set Up Process Mining in a Decentralized Organization?
How to Set Up Process Mining in a Decentralized Organization?
Process mining Evangelist
 
real illuminati Uganda agent 0782561496/0756664682
real illuminati Uganda agent 0782561496/0756664682real illuminati Uganda agent 0782561496/0756664682
real illuminati Uganda agent 0782561496/0756664682
way to join real illuminati Agent In Kampala Call/WhatsApp+256782561496/0756664682
 
Transforming health care with ai powered
Transforming health care with ai poweredTransforming health care with ai powered
Transforming health care with ai powered
gowthamarvj
 
AWS-Certified-ML-Engineer-Associate-Slides.pdf
AWS-Certified-ML-Engineer-Associate-Slides.pdfAWS-Certified-ML-Engineer-Associate-Slides.pdf
AWS-Certified-ML-Engineer-Associate-Slides.pdf
philsparkshome
 
AWS Certified Machine Learning Slides.pdf
AWS Certified Machine Learning Slides.pdfAWS Certified Machine Learning Slides.pdf
AWS Certified Machine Learning Slides.pdf
philsparkshome
 
Understanding Complex Development Processes
Understanding Complex Development ProcessesUnderstanding Complex Development Processes
Understanding Complex Development Processes
Process mining Evangelist
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
What is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdfWhat is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdf
SaikatBasu37
 
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial IntelligenceDr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug
 
Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]Language Learning App Data Research by Globibo [2025]
Language Learning App Data Research by Globibo [2025]
globibo
 
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdfTOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
TOAE201-Slides-Chapter 4. Sample theoretical basis (1).pdf
NhiV747372
 
L1_Slides_Foundational Concepts_508.pptx
L1_Slides_Foundational Concepts_508.pptxL1_Slides_Foundational Concepts_508.pptx
L1_Slides_Foundational Concepts_508.pptx
38NoopurPatel
 
problem solving.presentation slideshow bsc nursing
problem solving.presentation slideshow bsc nursingproblem solving.presentation slideshow bsc nursing
problem solving.presentation slideshow bsc nursing
vishnudathas123
 
Automated Melanoma Detection via Image Processing.pptx
Automated Melanoma Detection via Image Processing.pptxAutomated Melanoma Detection via Image Processing.pptx
Automated Melanoma Detection via Image Processing.pptx
handrymaharjan23
 
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
文凭证书美国SDSU文凭圣地亚哥州立大学学生证学历认证查询
Taqyea
 
Process Mining Machine Recoveries to Reduce Downtime
Process Mining Machine Recoveries to Reduce DowntimeProcess Mining Machine Recoveries to Reduce Downtime
Process Mining Machine Recoveries to Reduce Downtime
Process mining Evangelist
 
Sets theories and applications that can used to imporve knowledge
Sets theories and applications that can used to imporve knowledgeSets theories and applications that can used to imporve knowledge
Sets theories and applications that can used to imporve knowledge
saumyasl2020
 
national income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptxnational income & related aggregates (1)(1).pptx
national income & related aggregates (1)(1).pptx
j2492618
 
AWS RDS Presentation to make concepts easy.pptx
AWS RDS Presentation to make concepts easy.pptxAWS RDS Presentation to make concepts easy.pptx
AWS RDS Presentation to make concepts easy.pptx
bharatkumarbhojwani
 
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
2-Raction quotient_١٠٠١٤٦.ppt of physical chemisstry
bastakwyry
 
How to Set Up Process Mining in a Decentralized Organization?
How to Set Up Process Mining in a Decentralized Organization?How to Set Up Process Mining in a Decentralized Organization?
How to Set Up Process Mining in a Decentralized Organization?
Process mining Evangelist
 
Transforming health care with ai powered
Transforming health care with ai poweredTransforming health care with ai powered
Transforming health care with ai powered
gowthamarvj
 
AWS-Certified-ML-Engineer-Associate-Slides.pdf
AWS-Certified-ML-Engineer-Associate-Slides.pdfAWS-Certified-ML-Engineer-Associate-Slides.pdf
AWS-Certified-ML-Engineer-Associate-Slides.pdf
philsparkshome
 
AWS Certified Machine Learning Slides.pdf
AWS Certified Machine Learning Slides.pdfAWS Certified Machine Learning Slides.pdf
AWS Certified Machine Learning Slides.pdf
philsparkshome
 
Introduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdfIntroduction to systems thinking tools_Eng.pdf
Introduction to systems thinking tools_Eng.pdf
AbdurahmanAbd
 
What is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdfWhat is ETL? Difference between ETL and ELT?.pdf
What is ETL? Difference between ETL and ELT?.pdf
SaikatBasu37
 
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial IntelligenceDr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug - Expert In Artificial Intelligence
Dr. Robert Krug
 
Ad

database in my squel assignment for students.pdf

  • 3. Database A database is a collection of information that is organized so it can be easily accessed, managed, and updated. Think of it as a digital storage system where you can keep data, such as names, numbers, or records, and quickly find or change them when needed. For example, a database might store all the contact details for people in a company or all the products in a store SQL SQL (Structured Query Language) is a programming language used to manage and manipulate databases, specifically relational databases. It allows users to create, read, update, and delete data stored in tables. SQL is the standard language for interacting with most relational database systems.
  • 4. Key Functions of SQL: • Create: Make databases and tables. • Read: Retrieve data. • Update: Modify existing data. • Delete: Remove data.
  • 6. Types of SQL Commands: 1. Data Definition Language (DDL) o CREATE: Creates new database objects (e.g., tables). o ALTER: Modifies existing database structures. o DROP: Deletes database objects. o TRUNCATE: Removes all records from a table but keeps the structure. 2. Data Manipulation Language (DML) o SELECT: Retrieves data from the database. o INSERT: Adds new records into a table. o UPDATE: Modifies existing records in a table. o DELETE: Removes records from a table. 3. Data Control Language (DCL) o GRANT: Gives users access to the database. o REVOKE: Removes users' access rights. 4. Transaction Control Language (TCL) o COMMIT: Saves all changes made in the transaction. o ROLLBACK: Reverts changes if something goes wrong. o SAVEPOINT: Sets a point within a transaction to which you can later roll back. 5. Data Query Language (DQL) o SELECT: Used to query and fetch data from the database.
  • 7. 1. CREATE DATABASE o Definition: Creates a new database called student_info. 2. USE DATABASE o Definition: Selects the student_info database to work within it. 3. CREATE TABLE o Definition: Creates a table named student with specified columns such as id, name, age, batch, etc.
  • 8. 4. INSERT INTO o Definition: Inserts records into the student table.
  • 9. 5. SELECT o Definition: Retrieves data from the student table. The asterisk (*) selects all columns, while specific column names like city, name, and age select only those fields.
  • 10. 6. DISTINCT o Definition: Retrieves unique values from the specified column, avoiding duplicates
  • 11. 7. WHERE o Definition: Filters the results based on specified conditions
  • 12. 8. Arithmetic Operators in WHERE o Definition: Uses arithmetic operations within the WHERE clause.
  • 13. 9. Comparison Operators in WHERE o Definition: Compares values using operators like != (not equal) and >= (greater than or equal).
  • 14. 10. Logical Operators (AND) o Definition: Retrieves rows that satisfy both conditions.
  • 15. 11. Logical Operators (OR) o Definition: Retrieves rows that satisfy either of the conditions.
  • 17. Definition 12. BETWEEN o : Selects rows where a column's value falls within a specified range. 13. IN o Definition: Checks if a value exists within a specified set of values.
  • 18. Definition 14. NOT IN o : Selects rows where a value is not part of the specified set.
  • 19. Definition 15. LIMIT Definition: Limits the number of rows returned by the query. 16. ORDER BY o : Sorts the result set by the specified column (ascending or descending).
  • 20. Definition 17. COUNT (Aggregate Function) o Definition: Returns the number of rows that match a specified condition.
  • 21. 18. MAX (Aggregate Function) o Definition: Returns the maximum value of the specified column. 19. MIN (Aggregate Function) o Definition: Returns the minimum value of the specified column. 20. AVG (Aggregate Function) o Definition: Returns the average value of a numeric column.
  • 22. 21. SUM (Aggregate Function) o Definition: Returns the total sum of a numeric column. 22. GROUP BY o Definition: Groups rows with the same values into summary rows.
  • 23. 23. HAVING o Definition: Filters rows after the GROUP BY using aggregate conditions. 24. UPDATE o Definition: Updates existing records in a table.
  • 24. 25. DELETE o Definition: Deletes records from the table based on the condition. 26. ALTER TABLE o Definition: Modifies the structure of an existing table (adding, renaming, modifying, or removing columns).
  • 27. 27. TRUNCATE o Definition: Removes all rows from a table without deleting the table itself. 28. VIEW o Definition: Creates a virtual table based on the result of a SELECT query.
  • 28. 29. AS (Alias) o Definition: Provides an alias to column names.
  • 29. 30. LIKE o Definition: Retrieves rows where a column matches a specified pattern.
  • 30. Joins Create Database Creates a new database named joins. Use Database Selects the joins database for subsequent queries. Create Table – std_table Creates a std_table table with columns for student ID, name, and city. Create Table – sub_table Creates a sub_table table with columns for student ID and subject name.
  • 31. Insert Data into std_table Inserts student records into the std_table table. Insert Data into sub_table Inserts subject records into the sub_table table.
  • 32. Select all from std_table Retrieves all records from the std_table table.
  • 33. Select all from sub_table Retrieves all records from the sub_table table.
  • 34. Inner Join std_table and sub_table Returns matching records from both student and sub where std_id is the same in both tables. Left Join std_table and sub_table
  • 35. Returns all records from the std_table table and matching records from sub_table (if any). Right Join std_table and sub_table Returns all records from the sub_table table and matching records from std_table (if any) Cross Join std_table and sub_table Returns the Cartesian product of the std_table and sub_table tables (all combinations).
  • 36. ER DIAGRAM Create Database Definition: This query creates a new database named university_info. Select Database Definition: This query selects the university_info database for use. Create Faculty Table Definition: Creates the Faculty table with columns fac_id and faculty_name. Create School Table Definition: Creates the School table linked to the Faculty table via fac_id. Create Program Table Definition: Creates the Program table linked to the School table via scho_id.
  • 38. Definition: Creates the Courses table linked to the Program table via pro_id. Create Lecturers Table Definition: Creates the Lecturers table linked to the School table via scho_id. Create Course_Lecturer Table Definition: Creates the Course_Lecturer table to establish a many- tomany relationship between Courses and Lecturers. Create Students Table Definition: Creates the Students table linked to the Program table via pro_id.
  • 39. Create Enrollments Table Definition: Creates the Enrollments table to link students to courses.
  • 40. Insert Data into Faculty Table Definition: Inserts faculty records into the Faculty table. Insert Data into School Table Definition: Inserts school records into the School table, associating them with faculties. Insert Data into Program Table Definition: Inserts program records into the Program table, associating them with schools. Insert Data into Courses Table Definition: Inserts course records into the Courses table, linking them to programs. Insert Data into Lecturers Table Definition: Inserts lecturer records into the Lecturers table, associating them with schools.
  • 41. Insert Data into Course_Lecturer Table Definition: Links courses with lecturers in the Course_Lecturer table. Insert Data into Students Table Definition: Inserts student records into the Students table, linking them to programs. Insert Data into Enrollments Table Definition: Links students to courses in the Enrollments table.
  • 42. DIAGRAM DCL CREATE DATABASE tcl; Creates a new database named tcl. USE tcl; Selects the tcl database for future operations. CREATE TABLE std_info(...); Creates the std_info table with columns ID, NAME, AGE, and BATCH. INSERT INTO std_info ...; Inserts data into the std_info table. SELECT * FROM std_info; Retrieves all rows and columns from the std_info table.
  • 44. CREATE USER 'ali'@'localhost' IDENTIFIED BY 'ali1'; Creates a new user ali with password ali1. GRANT SELECT ON tcl.std_info TO 'ali'@'localhost'; Grants ali permission to read data from std_info. REVOKE INSERT ON tcl.std_info FROM 'ahmed'@'localhost'; Removes the INSERT permission from ahmed. FLUSH PRIVILEGES; Applies privilege changes. SELECT User, Host FROM mysql.user ...; Lists users ali, ahmed, and kabeer from the MySQL server. SHOW GRANTS FOR 'ali'@'localhost'; Displays the privileges granted to ali.
  • 45. TCL CREATE TABLE Definition: Creates a new table with specified columns. SELECT @@autocommit Definition: Checks the autocommit mode status. SET autocommit = 0 Definition: Disables autocommit mode so transactions must be manually committed. START TRANSACTION Definition: Begins a new transaction. INSERT INTO Definition: Inserts new data into a table. SELECT * FROM Definition: Retrieves all data from a table. ROLLBACK Definition: Undoes all changes made in the current transaction. COMMIT Definition: Permanently saves all changes made in the current transaction.
  • 46. UPDATE Definition: Modifies existing data in a table. SAVEPOINT Definition: Creates a checkpoint in a transaction, allowing rollback to this point.
  • 47. ROLLBACK TO SAVEPOINT Definition: Rolls back changes to a specific savepoint without affecting earlier changes.
  翻译: