0% found this document useful (0 votes)
33 views43 pages

SQL Basics: Commands and Functions Guide

The document provides an overview of SQL, focusing on its use in managing databases with MySQL. It outlines key concepts such as DDL (Data Definition Language) and DML (Data Manipulation Language), including basic commands for creating, altering, and querying tables. Additionally, it covers various SQL commands and clauses, including joins and aggregate functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views43 pages

SQL Basics: Commands and Functions Guide

The document provides an overview of SQL, focusing on its use in managing databases with MySQL. It outlines key concepts such as DDL (Data Definition Language) and DML (Data Manipulation Language), including basic commands for creating, altering, and querying tables. Additionally, it covers various SQL commands and clauses, including joins and aggregate functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL ONE SHOT

By Devender Singh(under 30 minutes)


SQL
• Structured query language
• Used to manage sql database
MYSQL
• MySql is a software which uses SQL as the query language .
• It works on your system as well as cloud
DDL
• Stands for data definition language
• Consists of CAD :
create
alter
drop
DML
• Stands for data manipulation language
• Consists of SIDU :
select
insert
update
delete
BASIC COMMANDS
USE
• Use {database name}
• Enters the given database
SHOW
• Show tables;
• Show tables in {database name};
DESC
• Desc {table name};
• Used to display structure of table
TRUNCATE
• Truncate {table/database} {table name/database name};
• Used to delete all records in a specific table[does not delete the table]
DDL COMMANDS
CREATE
• Create database {database name};

• Create table {table name}({define table here});


• Datatypes : -

int
varchar()
char()
date
bigint(),smallint()
decimal(before decimal , after decimal )
CONSTRAINTS
• Primary key
• Not null
• Unique
• Foreign key
ALTER
• Alter table {table name} add/modify/drop column/constraint {name}
{features};
DROP
• Drop {table/database} {table name/database name}
DML COMMANDS
WHERE CLAUSE
• It’s a conditional statement
• Operators used are : like , = , > , < , >= , <= , !=, is

• Where {column name} {operator} {value}


SELECT
• Select {what to select } from {table name} {conditional statement};
• * means everything
AS CLAUSE
• In select you can name a column
INSERT
• Insert into {table name}(column names) values();
DELETE
• Delete from {table name} {conditional statement};
UPDATE
• Update {table name} set {column name}={value} {conditional statement};
AGGREGATE FUNCTION
• Sum() : gives the sum
• Count : gives length
• Min() : gives minimum
• Max() : gives maximum
• Avg() : gives the arithmetic mean
GROUP BY CLAUSE
• Groups by column , used in aggregate functions
HAVING CLAUSE
• Conditional statement for group by
JOINS
CARTESION PRODUCT/CROSS JOIN
• A,B
• A cross join B
INNER OR EQUI JOIN
• A inner join B
NATURAL JOIN
• A natural join B
LEFT OUTER JOIN
• A left outer join B
RIGHT OUTER JOIN
• A right outer join B
FULL OUTER JOIN
• You have to take a union between left and right outer join to get full outer
join
QUESTIONS
THANKS

You might also like