0% found this document useful (0 votes)
6 views14 pages

SQL Basics: Commands and Queries Guide

The document provides an introduction to SQL, detailing its purpose for interacting with relational databases and performing CRUD operations. It covers various SQL command categories, database creation, data types, constraints, keys, basic queries, clauses, aggregate functions, and joins. Additionally, it explains subqueries and views, concluding with a thank you note.

Uploaded by

suryatejdasari19
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views14 pages

SQL Basics: Commands and Queries Guide

The document provides an introduction to SQL, detailing its purpose for interacting with relational databases and performing CRUD operations. It covers various SQL command categories, database creation, data types, constraints, keys, basic queries, clauses, aggregate functions, and joins. Additionally, it explains subqueries and views, concluding with a thank you note.

Uploaded by

suryatejdasari19
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to SQL

• SQL: Structured Query Language


• Used to interact with relational databases
• Performs CRUD operations: Create, Read,
Update, Delete
Types of Databases

• Relational (SQL): Data stored in tables


• Non-relational (NoSQL): Data not stored in
tables
SQL Commands Categories

• DDL: create, alter, drop, rename, truncate


• DML: select, insert, update, delete
• DCL: grant, revoke
• DQL: select
• TCL: commit, rollback
Creating Databases & Tables

• CREATE DATABASE db_name;


• DROP DATABASE db_name;
• CREATE TABLE table_name (column_name
datatype constraint);
SQL Datatypes

• TINYINT, INT, VARCHAR, DATE, etc.


• Signed & Unsigned ranges for numeric types
Constraints in SQL

• NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN


KEY
• DEFAULT, CHECK
Keys in SQL

• Primary Key: Uniquely identifies each row


• Foreign Key: Refers to Primary Key in another
table
Basic Queries

• SELECT * FROM table_name;


• INSERT INTO table_name (cols) VALUES (vals);
• UPDATE table_name SET col = val WHERE
condition;
• DELETE FROM table_name WHERE condition;
Clauses in SQL

• WHERE: Filtering rows


• ORDER BY: Sort results
• LIMIT: Limit number of rows returned
Aggregate Functions

• COUNT(), SUM(), AVG(), MIN(), MAX()


• Often used with GROUP BY
GROUP BY and HAVING

• GROUP BY: Groups rows into summary rows


• HAVING: Filters after grouping
Joins in SQL

• INNER JOIN: Matching rows from both tables


• LEFT JOIN / RIGHT JOIN: All rows from one
table, matched from another
• FULL JOIN: All rows from both tables
• SELF JOIN: Join table with itself
Subqueries & Views

• Subquery: Nested SELECT inside WHERE or


FROM
• Views: Virtual table based on SQL query result
End of Presentation

• Thank you!

You might also like