DB Report
DB Report
DB Report
What is Database?
Database is a collection of records .Database stored the data in rows and
columns format this is also known as RDBMS(Relational Database
Management System).
Types of Database :
1) Centralized Database: It is the type of database that stores data
at a centralized database system. It comforts the users to access the stored
data from different locations through several applications.
2) Distributed Database: These database systems are connected via
communication links. Such links help the end-users to access the data
easily.
3) Relational Database: This database is based on the relational data
model, which stores data in the form of rows(tuple) and
columns(attributes), and together forms a table(relation).
4) NOSQL Database: Non-SQL/Not Only SQL is a type of database
that is used for storing a wide range of data sets
5) Cloud Database: A type of database where data is stored in a
virtual environment and executes over the cloud computing platform
Query:
1) create table student(id int primary key,name varchar(255),city
varchar(255));
Database Command:
• DDL : Data definition language : which are used to create the structure
of the database as well as related activities are called DDL commands
like create table commands and alter commands
student.id=fees.s_id;
LEFT JOIN:
the left join table all return from the left table and the matched record from
the right table
Query: select*from student left join fees on student.id=fees.s_id
RIGHT JOIN:
The right join table all return from the right table and the matched record
from the left table
Query:
select*from student Right join fees on student.id=fees.s_id;
Cross join:
The SQL ORDER BY Keyword: The Order By keyword is
used to sort the result-set in ascending or descending order .
Query
create table student (id int primary key,name varchar(255),city
varchar(255));
insert into student values(1,'Raju','Allahabad');
insert into student values(2,'mohan','Phulpur');
insert into student values(3,'mukesh','Bhadohi');
insert into student values(4,'Rehan','Mumbai');
Ascending order:
1) Query
select name from student order by name asc;
2) Descending order.
3) Query
select name from student order by name desc;
EXAMPLE
select * from student order by city;:
;
Operater: There are Three Types
AND Opreater:
The AND operator displays a record if all the conditions
separated by AND are TRUE.
Query
select*from student1 where name='monu' and
address='USA';
EXAMPLE:
select*from student1 where age='22' and address='USA';
OR Operators:
The OR operator displays a record if any of the conditions
separated by OR is TRUE.
Query:
select*from student1 where name='monu' or
address='USA';
Query:
update student set name='sunil' where id='1';
1. Query
update student1 set age='22', name='rohit'where id='5';
SQL DELETE Statement:
The DELETE statement is used to delete existing records in a
table.
1. Query:
delete from student1 where name='rohit';
SQL MIN() and MAX() Functions:
1)MIN()
The MIN() function returns the smallest value of the selected
column.
1. Query:
select min(age) from student1;
MAX:
The MAX() function returns the largest value of the selected
column.
1. Query:
select max(age) from student1;
SQL COUNT(), AVG() and SUM() Functions:
The COUNT() function returns the number of rows that matches
a specified criterion
(count function are used to count data each row and each
column of table)
AVG():
He AVG() function returns the average value of a numeric
column.
Query:
select avg(marks)from student2 where id='1';
Query:
select sum(marks)from student2;
SQL ALTER TABLE Statement: I
Query:
alter table student1 DROP COLUMN Email;