Rdbms File
Rdbms File
OF
RELATIONAL
DATABASE
MANAGEMENT
SYSTEM (RDBMS)
INDEX
SR. QUARRY NAME PAGE
NO. NO.
1 INTRODUCTION
2 INTRODUCTION TO MYSQL
3 INSTALLATION OF MYSQL
4 CREATE DATABASE STATEMENT
5 CREATE TABLE STATEMENT
6 RETRIEVAL OF ROW USING SELECT STATEMENT
7 CONDITIONAL RETRIEVAL OF ROWS STATEMENT
8 MY SQL ALTER AND DROP STATEMENT
9 UPDATE AND DELETE STATEMENT
10 JOIN SEQUENCES
11 COMMIT AND ROLLBACK
12 MYSQL IS NULL CONDITION
13 MYSQL AGGREGATE FUNCTION
14 ORDERING THE RESULT OF QUERIES
15 MYSQL OPERATORS
16 GROUPING THE RESULT OF QUERIES
17 LOWER QUERY
18 UPPER QUERY
19 LENGTH QUERY
20 CONCAT QUERY
21 INSTR QUERY
22 SUBSTR QUERY
23 UNION OF ALL OPERATOR
24 INTERSECTION OPERATOR
25 INTERSECTION ALL STATEMENT
26 CREATE VIEW STATEMENT
27 CREATE INDEX STATEMENT
28 UNIQUE INDEX STATEMENT
29 DROP INDEX
30 PL/SQL ARCHITECTURE
INTRODUCTION
Structured Query Language( SQL)
SQL Database
Here, we will discuss the queries and will
understand with the help of examples
Queries :
Example:
Query:
Create a database –
Suppose we want to create a database namely a student
Query:
Describe- to describe the structure of the table
record. Syntax
Describe table_name;
Example17
Query:
Insert- is used to insert values into an existing
table. Syntax
INSERT INTO table_name (column1, column2, column3, ...);
Example:
Example
● LIKE operator:
The LIKE operator is used in a WHERE clause to
search for a specified pattern in a column. There
are two wildcards often used in conjunction with
the LIKE operator:
● The percent sign (%) represents zero, one, or
multiple characters
● The underscore sign (_) represents one, single
character Syntax:
SELECT column1, column2, ...FROM
table_name WHERE column LIKE pattern;
Example:
(II) Ordering the Result of a Query:
ORDER BY- The ORDER BY keyword is used to
sort the result-set in ascending or descending
order. The ORDER BY keyword sorts the records
in ascending order by default. To sort the records
in descending order, use the DESC keyword.
Syntax: SELECT column1, column2, ...FROM
table_name ORDER BY column1, column2, ...
ASC| DESC;
Example:
(III) AGGREGATE FUNCTIONS:
An aggregate function in SQL performs a calculation
on multiple values and returns a single value. SQL
provides many aggregate functions that include avg,
count, sum, min, max, etc. An aggregate function
ignores NULL values when it performs the
calculation, except for the count function.
(i) COUNT( ) FUNCTION
The COUNT( ) function returns the number of rows
that matches a specified criterion.
Syntax:
SELECT COUNT(column_name)FROM
table_name WHERE condition;
Example:
(ii)AVG( ) FUNCTION
The AVG( ) function returns the average
value of a numeric column.
Syntax:
SELECT AVG(column_name) FROM
table_name WHERE condition;
Example:
Syntax:
SELECT column_name(s)FROM table_name
WHERE condition GROUP BY column_name(s)
ORDER BY column_name(s);
Example:
DELETE
The DELETE statement is used to delete
existing records in a table.
Syntax:
DELETE FROM table_name WHERE condition;
Example :
Output:
MySQL Aggregate Functions
MySQL's aggregate function is used to perform
calculations on multiple values and return the result
in a single value like the average of all values, the
sum of all values, and maximum & minimum value
among certain groups of values. We mostly use the
aggregate functions with SELECT statements in the
data query languages. Syntax:
mysql> SELECT COUNT(name) FROM
students;
Count() Function
MySQL count() function returns the total
number of values in the expression. This
function produces all rows or only some rows
of the table based on a specified condition, and
its return type is BIGINT. It returns zero if it
does not find any matching rows. It can work
with both numeric and non-numeric data types.
Example
Suppose we want to get the total number of
employees in the employee table, we need to use the
count() function as shown in the following query:
mysql> SELECT COUNT(name) FROM rana;
Output:
Ordering the result of
queries Syntax:-
select * from student order by Roll_No desc;
MySQL Operators.
The MySQL IN condition is used to reduce the
use of multiple OR conditions in a SELECT,
INSERT, UPDATE and DELETE statement.
In Operator
Syntax:
SELECT * FROM students WHERE city =
'sirhind’
OR
city = 'patiala';
Output:
AND Syntax
SELECT column1, column2, ...
FROM table_name
NOT Syntax
SELECT column1, column2, ...
FROM table_name
UPPER.
The SQL UPPER () function is used to
convert all characters of a string to
uppercase. Syntax: UPPER(SQLcourse)
example:
Length.
This function returns the length
of the input string. Syntax:
LENGTH (Column | Expression)
Example:
CONCAT-
This function always appends (concatenates) string2 to
the end of string1.
Syntax: CONCAT ('String1', 'String2')
Example:
INSTR.
This function returns numeric position of a
character or a string in a given string.
Syntax: INSTR (Column | Expression, 'String', [,m],
[n]) Example
SUBSTR.
This function returns a portion of a string from a given
start point to an end point.
Syntax: SUBSTR ('String', start-index, length of
extracted string)
Example:
Union
ALL operator A union is used for extracting rows using
the conditions specified in the query while Union All is
used for extracting all the rows from a set of two tables.
Syntax: select column name(s) from table1 UNION
ALL Select column name(s)from table2;
Intersection operator
The UNION ALL command combines the result set of two
or more SELECT statements (allows duplicate values).
Syntax: select column name(s) from
table1 Intersect
Select column name(s)from table2;
Intersection ALL statement
PL/SQL Architecture
PL/SQL Functionalities
PL/SQL is not case sensitive so you are free to use lower case
letters or upper case letters except within string and character
literals. A line of PL/SQL text contains groups of characters
known as lexical units. It can be classified as follows:
○ Delimeters
○ Identifiers
○ Literals
○ Comments
Features of PL/SQL :
PL/SQL Architecture
PL/SQL can reside in two environments –
Advantages of PL/SQL :
● PL/SQL provides better performance.
● PL/SQL has high Productivity.
● It supports Object-Oriented Programming concepts.
● It has Scalability and Manageability.
● PL/SQL supports various Web Application
Development tools.
Disadvantages of PL/SQL :