Structured Query Language (SQL) : By:-Amit Yerpude PGT (Computer Science) Kendriya Vidyalaya, Khagaria
Structured Query Language (SQL) : By:-Amit Yerpude PGT (Computer Science) Kendriya Vidyalaya, Khagaria
By:-
Amit Yerpude
PGT (Computer Science)
Kendriya Vidyalaya , Khagaria
2
Basic Database concepts Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
STRUCTURED QUERY
LANGUAGE
(SQL)
7
Structured Query LanguagePresented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
Characteristics of SQL
3. View Definition:
GRANT, REVOKE
11
Structured Query Language
Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
COMMIT, ROLLBACK
12
Data types of SQL Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
1. NUMBER
2. CHAR
3. VARCHAR / VARCHAR2
4. DATE
5. LONG
6. RAW/LONG RAW
13
Data types of SQL Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
1. NUMBER
Number(n,d)
2. CHAR
3. VARCHAR/VARCHAR2
varchar(size) / varchar2(size)
4. DATE
5. LONG
6. RAW/LONG RAW
Constraints:
1. NOT NULL
2. UNIQUE
3. PRIMARY KEY
4. FOREIGN KEY
5. CHECK
6. DEFAULT
21
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
Constraints:
Constraints:
Constraints:
Constraints:
Constraints:
Operators in SQL:
INSERT Statement
The simplest way to insert a tuple into a table is to use the
insert statement
INSERT Statement
In the above command the values for all the columns are
read from keyboard and inserted into the table student.
TABLE : STUDENT
Queries:
SELECT Command
SELECT Command
SELECT Command
Name
Rohan
Aneeta
Pawan Kumar
35
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
SQL provides two wild card characters that are used while
comparing the strings with LIKE operator.
ORDER BY Clause
ORDER BY Clause
GROUP BY Clause
GROUP BY Clause
GROUP BY city;
43
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
HAVING Clause
HAVING Clause
1. Mathematical functions
2. String functions
1. Mathematical functions
2. String functions
These functions are used to deal with the string type values
like
Syntax: ASCII(character)
48
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
2. String functions
2. String functions
2. String functions
Syntax: LOWER(string)
2. String functions
Syntax: UPPER(string)
2. String functions
Syntax: LEN(string)
returns 15
53
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
2. String functions
Syntax: REPLACE('string1','string2','string3')
2. String functions
Syntax: LEFT(string,integer)
returns STRING
55
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
2. String functions
Syntax: RIGHT(string,integer)
returns FUNCTION
56
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
2. String functions
Syntax: LTRIM(string)
2. String functions
2. String functions
Syntax: REVERSE(string)
2. String functions
SELECT REPLICATE('FUNCTION', 3)
returns FUNCTIONFUNCTIONFUNCTION
60
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
2. String functions
2. String functions
2. String functions
returns STRING
returns FUNCTION
63
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
DELETE Command
UPDATE Command
UPDATE Command
Adding a column
The syntax to add a column is:-
If we give command
TABLE : STUDENT
Khagaria
Note that we have just added a column and there will be no data
under this attribute. UPDATE command can be used to supply
values / data to this column.
72
SQL Commands Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
Removing a column
i. Database Abstraction
Ans: When two or more entries about the same data do not
agree i.e. when one of them stores the updated information
and the other does not, it results in data inconsistency in the
database.
76
Relational Algebra Presented By:- Amit 8/5/2020
Yerpude, PGT CS, KV
Khagaria
v. Candidate Key
vii. Domain
Thank You
Very Much