PRAVEEN M JIGAJINNI
PGT (Computer Science)
MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA,
Dc. Sc. & Engg.
email: praveenkumarjigajinni@yahoo.co.in
STRUCTURED QUERY
LANGUAGE(SQL)
Basic Database concepts
Characteristics of SQL
3. View Definition:
GRANT, REVOKE
Structured Query Language
COMMIT, ROLLBACK
Data types of SQL
1. NUMBER
2. CHAR
3. VARCHAR / VARCHAR2
4. DATE
5. LONG
6. RAW/LONG RAW
Data types of SQL
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
SQL Commands
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
SQL Commands
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;
SQL Commands
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)
SQL Commands
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
SQL Commands
2. String functions
Syntax: REPLACE('string1','string2','string3')
2. String functions
Syntax: LEFT(string,integer)
returns STRING
SQL Commands
2. String functions
Syntax: RIGHT(string,integer)
returns FUNCTION
SQL Commands
2. String functions
Syntax: LTRIM(string)
2. String functions
2. String functions
Syntax: REVERSE(string)
2. String functions
SELECT REPLICATE('FUNCTION', 3)
returns FUNCTIONFUNCTIONFUNCTION
SQL Commands
2. String functions
2. String functions
2. String functions
returns STRING
returns FUNCTION
SQL Commands
DELETE Command
UPDATE Command
UPDATE Command
Adding a column
The syntax to add a column is:-
If we give command
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.
SQL Commands
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.
Relational Algebra
v. Candidate Key
vii. Domain