INDEX
SQL and classification of its statements
SQL Commands:
Viewing already created databases
Creating databases
Accessing databases
Drop databases
Viewing already created tables
Renaming tables
Creating tables
Inserting data into tables
Making simple queries through SELECT command
Creating tables with SQL constraints
Viewing a table structure
Modifying data in tables
Deleting data from tables
Altering tables
Dropping tables
Order by clause
AGGREGATE FUNCTIONS
o AVG
o COUNT
o MAX
o MIN
o SUM
JOIN
MYSQL
MySQL is a freely available open-source
Relational Database Management System
(RDBMS) that uses Structured Query Language
(SQL). In a MySQL database, information is
stored in tables.
The Structured Query Language (SQL) is a
language that enables you to create and operate
on relational databases, which are sets of
related information stored in tables.
CLASSIFICATION OF SQL STATEMENTS :
Data Definition Language (DDL) Commands: Commands
that allow you to perform tsks related to data definition such as
creating, altering and dropping or maintenance commands,
Data Manipulation Language (DML) Commands:
Commands that allow you to perform data manipulation such as
retrieval, insertion, deletion and modification of data stored in a
database,
Transaction Control Language (TCL) Commands:
Commands that allow you to manage and control the
transactions.
MYSQL COMMANDS
o Viewing existing databases:
> show databases;
o Creating databases:
> create database <database name>;
o Accessing databases:
> use <database name>;
o Drop database:
>drop database <database name>;
o Viewing tables:
> show tables;
o Rename Table:
> alter table <old> rename <new>;
o Creating Tables:
> create table <name>(<column>
<datatype>[size] ….);
o Inserting data into tables:
> insert into <tablename> values (<value>,
<value>….);
o Viewing a table structure:
> desc <tablename>;
QUERIES THROUGH SELECT
COMMAND:
o Selecting all data:
Select * from <table>;
o Selecting particular rows:
Select * from <table> where <condition>;
o Selecting particular columns:
Select <column>, <column> from <table>;
AGGREGATE FUNCTIONS
SUM()
COUNT() MIN()
Functions
MAX() AVG()
JOIN
A JOIN combines records from two tables.
JOIN matches related column values in two
tables.
A query can contain zero, one, or multiple JOIN
operations.
TABLE: BOOKS
ID Name Publisher Price
1 Tears First Pub. 300
2 Fast Cook TDH 900
3 C++ EPB 700
TABLE: ISSUED
ID Quantity
1 56
3 34
select books.id,name,price from books, issued
where books.id=issued.id ;
ID NAME PRICE
1 Tears 300
3 C++ 700