Professional Documents
Culture Documents
On SQL
On SQL
I’m
Nitesh Sharma
1
Presentation
ON
SQL & COMMANDS
2
About SQL
SQL (Structured Query Language) is a
standard language for assessing and
manipulating databases.
By using SQL commands one can create
data bases and perform other functions
like create tables , add records , modify
3
software . It provides
some MySQL
useful features like
creating ,
sorting manipulating
and
assessing data stored in
the
SQL COMMANDS
• DROP • UPDATE
• ALTER • DELETE
5
Creating databases
SYNTAX
CREATE DATABASE [if not exist] <database_name>
Opening databases
Use <database_name> ;
To check databases
Show <database_name> ;
6
CREATE Command
SYNTAX
Create <table_name>
(
<column_name> <datatype> [(<size>)] ,
<column_name> <datatype> [(<size>)]...
);
7
Write queries for the following questions :
9
Write queries for the following questions :
11
ALTER Command
ALTER TABLE – ALTER/MODIFY COLUMN
SYNTAX
ALTER TABLE <table_name>
ALTER COLUMN <column_name> <datatype> <(size)>;
13
UPDATE Command
SYNTAX
UPDATE <table_name> SET <column1> = <value1> ,
<column2> = <value2>
WHERE condition ;
14
Write queries for the following questions :
15
Output , Result
16
SELECT
To see the entire table or records in the table
SYNTAX
Select * <table_name> ;
OR
Select <column1> , <column2>
from <table_name> ;
17
SELECT with WHERE Clause
To view certain records or rows from table
SYNTAX
Select * from <table name>
Where <condition> ;
Relational Operators
= , > , < , >= , <= , <> ( not equal to)
18
Write queries for the following questions :
1. Reema wants to see the records of those whose id is
1004 .
Emp_Name Phone_No
2.
Atul 931845XXXX
Harsh 836821XXXX
Mohit 876631XXXX
Nikhil 881038XXXX
20
DELETE Command
To delete the existing records from the table
SYNTAX
DELETE FROM <table_name> WHERE <condition> ;
DELETE Command
To delete All the records from the table
SYNTAX
DELETE FROM <table_name> ;
21
Example , Database – Emp1db
Table Name ~ Employee
Emp_Name Emp_ID Phone_No City_Country
22
Write queries for the following questions :
24
Example , Database – Emp1db
Table Name ~ Employee
Emp_Name Emp_ID Phone_No City_Country
25
DROP Command
To Delete the whole table
SYNTAX
DROP Command
To delete the database
SYNTAX
DROP DATABASE <database_name> ;
26
Write queries for the following questions :
27
Output , Result 3,4 :
Following the query , You will not
find any database with name
Emp1db and table with the name
Employee .
That means the table employee has
been deleted from the database
Emp1db and the database too.
28
Thanks !
29