SlideShare a Scribd company logo
Database
What is Database ?


• Database is a collection of data in an
  organized way so that we can update, modify
  data present in database easily.
• Data storage in database is permanent.
• Eg: Oracle, MySQL, MS-Access, DB2, Sybase
How to store data in database?


• Data will stored in “Tables” in database in the
  form of “Records”.
• Table is a collection of relational data in 2D i.e
  in the form of rows and columns.
What is SQL ?


• SQL – Structure Query Language
• It is language used to access and modify the data
  stored in database.
• It uses statements to access the database.
• SQL Statements can be divided into two types:
   DML
   DDL
DDL(Data Definition Language)


• These statements are used for creation or
  deletion of database.
• The commands present in DDL are:
   Create
   Alter
   Drop
Create

• This command is used to create table or
  database.

• create database;//to create database

• create table table_name(column1_name
  datatype,column2_name datatype); // to create
  table
Alter

• This command is used to rename a table or column name of an
  existing table.

• It can also be used to modify, add, drop a column/field present in
  an existing table.

• alter table table_name rename new_table_name; //to rename
  table

• alter table table_name rename column old_column_name to
  new_column_name; //to rename column
Alter

• alter table table_name add column_name datatype;
  //to add a column to table

• alter table table_name modify column_name
  new_datatype; //to modify datatype of column of a
  table

• alter table table_name drop column column_name;
  //to drop a column of a table
Drop


• This command is used to remove an
  object(value).
• We can not get the table or values in it once
  the table is dropped.
• drop table table_name; //to drop a table
DML(Data Manipulation Language)


• These statements are used for managing the
  data in database.
• The commands present in DDL are:
   Insert
   Update
   Delete
   Select
Insert

• This command is used to enter the records
  into the table.

• insert into table_name values(‘value_col_1’,
  ‘value_col_2’); //to insert values into table
Update

• This command is used to update the value of a record
  or column of a table.
• We use condition to know where the updation is to be
  made.

• update table set column_name=“value” where
  some_column_name = “value_of_some_column”;
  //to update the column where it satisfies condition
Delete


• This command is used to delete the records (one or
  many) from a table by specifying some condition
  where to delete the record.

• delete from table_name where column_name =
  “value”;
 //to delete record where it satisfies given condition
select

• Select command is used to retrieve the records from
  the table.

• select column1_name, column2_name,…………. from
  table_name; //to select the specific columns from
  table

• select * from table_name; // to retrieve all records
  present in table
Integrity Constraints


•   Not Null
•   Unique
•   Primary Key
•   Foreign Key
•   Check
Not Null

• It is a constraint that ensures that every row is
  filled with some value for the column which has
  been specified as “not null”.

• create table table_name
  (column1_name datatype NOT NULL,
  column2_name datatype );
Unique

• It is a constraint used for column of a table so
  that rows of that column should be unique.
• It allows null value also.

• create table table_name(
  column1_name datatype UNIQUE,
  column2_name datatype);
Primary Key

• It is a constraint used for a column of a table
  so that we can identify a row in a table
  uniquely.
• create table table_name(
• column1_name datatype PRIMARY KEY,
• column2_name datatype);
Foreign key

• It is a constraint used to establish a relationship between
  two columns in the same or different tables.

• For a column to be defined as a Foreign Key, it should be a
  defined as a Primary Key in the table which it is referring.

• One or more columns can be defined as Foreign key.
• This constraint identifies any column referencing the
  PRIMARY KEY in another table.
SQL clauses


  •   select   • order by
  •   from     • group by
  •   where    • having
  •   update
Order by


• This clause is used the values of a column in
  ascending or descending order.
• select empname from emp1
  order by empname;
Group by


• This clause is used to collect data across
  multiple records and group results by one or
  more columns.
• select department from Student
  where subject1> 20
  group by department;
Having


• This clause is used in combination with sql group
  by clause.
• It is used to filter the records that a sql group by
  returns.
• select max(subject1) from Student
  group by department
  having min(subject1)>20;
Basic Functions

• COUNT() – to count the number of records satisfy
              condition.
• MAX()- to find the maximum value of a column of all
          the records present in table.
• MIN()- to find the minimum value of a column of
         all the records present in table.
• AVG()- to find the average value of a column of
         all the records present in table.
• SUM()- to find the sum of all the values of a column
          in a table.
Basic Functions

• AVG()- to find the average value of a column
         of all the records present in table.
• SUM()- to find the sum of all the values of a
          column in a table.
• Distinct() - to find the distinct record of a table
Joins

• Join is used to retrieve data from two or more
  database tables.
• Joins are of four types:
 Cross join- This join returns the combination of
  each row of the first table with every column of
  second table.
 Inner join-This join will return the rows from both
  the tables when it satisfies the given condition.
Joins

 Left Outer join –suppose if we have two tables. One on
  the left and the other on right side.

      When left outer join is applied on these two tables it
  returns all records of the left side table even if no
  matching rows are found in right side table

 Right Outer join- it is converse of left outer join. It
  returns all the rows of the right side table even if no
  matching rows are found in left side table.
JDBC
JDBC


• JDBC-Java Database Connectivity.
• JDBC is an API that helps us to connect our
  java program to the database and do the
  manipulation of the data through java
  program.
How to write a program in jdbc?


•   Register the Driver
•   Connecting to database
•   Create SQL statement in java
•   Execute SQL statements
•   Retrieve Result
•   Close Connection
JDBC program
public class JDBCProgram{
public static void main(String[] args) {
try {
        Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);//REGISTERING DATABASE
        Connection con = DriverManager.getConnection("jdbc:odbc:dsn", "",""); //CONNECTING DATABASE
        Statement st=con.createStatement();//CREATE STATEMENT
        st.execute("create table Employee(empid integer, empname varchar(50))");//EXECUTING STATEMENT
        st.close();// CLOSING STATEMENT
        con.close();//CLOSING CONNECTION
    }
catch (Exception err) {
      System.out.println( "Error: " + err );
      }
}
}
How to insert values into table using jdbc?

• To insert the values into the table we use prepared statement.

• PreparedStatement ps = con.prepareStatement("insert into
  Table_name(col1,col2)values(?,?)");//creating preparedstatement

  ps.setInt(1,value_col1);//inserting the value in column1
  ps.setString(2, “value_col2”); //inserting the value in column2

  ps.executeUpdate();//to execute the prepared statement
How to update values in table using jdbc?

• To update the values into the table also we use prepared statement.

• PreparedStatement ps = con.prepareStatement(“update Table_name set
  col1=?,col2=? where col1=?);//creating preparedstatement

  ps.setInt(1,new_value_col1);//updating new value in column1
  ps.setString(2, “value_col2”); //updating the value in column2
  ps.setInt(1,old_value_col1);//getting old value of column1
  ps.executeUpdate();//to execute the prepared statement
How to delete record in table using jdbc?

• To delete the record in the table also we use prepared statement.

• PreparedStatement ps = con.prepareStatement(“delete from Table_name
  where col1=?); //creating preparedstatement

  ps.setInt(1,old_value_col1);//getting value of column1
  ps.executeUpdate();//to execute the prepared statement
How to retrieve record from table using jdbc?

• To store the retrieved records we should use ResultSet.

• ResultSet rs = st.executeQuery("select * from Employee"); //using
  result set to store the result
  while(rs.next())
  {
  System.out.println(rs.getInt(1)); //to retrieve value of col1
  System.out.println(rs.getString(2)); //to retrieve value of
                                          col2
  }
•Q& A..?
Thanks..!

More Related Content

What's hot

SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsAshwin Dinoriya
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
Abrar ali
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
Sankhya_Analytics
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
HudaRaghibKadhim
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
SarithaDhanapal
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
Vidyasagar Mundroy
 
DML Commands
DML CommandsDML Commands
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 

What's hot (19)

SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
8. sql
8. sql8. sql
8. sql
 
Sql DML
Sql DMLSql DML
Sql DML
 
Dml and ddl
Dml and ddlDml and ddl
Dml and ddl
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
Sql commands
Sql commandsSql commands
Sql commands
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
 
DML Commands
DML CommandsDML Commands
DML Commands
 
1 ddl
1 ddl1 ddl
1 ddl
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 

Viewers also liked

Java class 1
Java class 1Java class 1
Java class 1Edureka!
 
Java class 7
Java class 7Java class 7
Java class 7Edureka!
 
Java class 4
Java class 4Java class 4
Java class 4Edureka!
 
Java class 5
Java class 5Java class 5
Java class 5Edureka!
 
Java class 3
Java class 3Java class 3
Java class 3Edureka!
 
Java class 6
Java class 6Java class 6
Java class 6Edureka!
 
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
Edureka!
 

Viewers also liked (8)

Java class 1
Java class 1Java class 1
Java class 1
 
Java class 7
Java class 7Java class 7
Java class 7
 
Java class 4
Java class 4Java class 4
Java class 4
 
Java
Java Java
Java
 
Java class 5
Java class 5Java class 5
Java class 5
 
Java class 3
Java class 3Java class 3
Java class 3
 
Java class 6
Java class 6Java class 6
Java class 6
 
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
What Is Salesforce CRM? | Salesforce CRM Tutorial For Beginners | Salesforce ...
 

Similar to Java class 8

2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
MalaikaRahatQurashi
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
Priyabrat Kar
 
Adbms
AdbmsAdbms
Adbms
jass12345
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
 
3. ddl create
3. ddl create3. ddl create
3. ddl create
Amrit Kaur
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
To Sum It Up
 
Structured Query Language(SQL)
Structured Query Language(SQL)Structured Query Language(SQL)
Structured Query Language(SQL)
PadmapriyaA6
 
SQL
SQLSQL
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
MARasheed3
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Dbms
DbmsDbms
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
TamiratDejene1
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
Amrit Kaur
 
OracleSQLraining.pptx
OracleSQLraining.pptxOracleSQLraining.pptx
OracleSQLraining.pptx
Rajendra Jain
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
Farhan Aslam
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
Sankhya_Analytics
 

Similar to Java class 8 (20)

2..basic queries.pptx
2..basic queries.pptx2..basic queries.pptx
2..basic queries.pptx
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Adbms
AdbmsAdbms
Adbms
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
3. ddl create
3. ddl create3. ddl create
3. ddl create
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
Structured Query Language(SQL)
Structured Query Language(SQL)Structured Query Language(SQL)
Structured Query Language(SQL)
 
SQL
SQLSQL
SQL
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Dbms
DbmsDbms
Dbms
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
OracleSQLraining.pptx
OracleSQLraining.pptxOracleSQLraining.pptx
OracleSQLraining.pptx
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 

More from Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 

Java class 8

  • 2. What is Database ? • Database is a collection of data in an organized way so that we can update, modify data present in database easily. • Data storage in database is permanent. • Eg: Oracle, MySQL, MS-Access, DB2, Sybase
  • 3. How to store data in database? • Data will stored in “Tables” in database in the form of “Records”. • Table is a collection of relational data in 2D i.e in the form of rows and columns.
  • 4. What is SQL ? • SQL – Structure Query Language • It is language used to access and modify the data stored in database. • It uses statements to access the database. • SQL Statements can be divided into two types: DML DDL
  • 5. DDL(Data Definition Language) • These statements are used for creation or deletion of database. • The commands present in DDL are: Create Alter Drop
  • 6. Create • This command is used to create table or database. • create database;//to create database • create table table_name(column1_name datatype,column2_name datatype); // to create table
  • 7. Alter • This command is used to rename a table or column name of an existing table. • It can also be used to modify, add, drop a column/field present in an existing table. • alter table table_name rename new_table_name; //to rename table • alter table table_name rename column old_column_name to new_column_name; //to rename column
  • 8. Alter • alter table table_name add column_name datatype; //to add a column to table • alter table table_name modify column_name new_datatype; //to modify datatype of column of a table • alter table table_name drop column column_name; //to drop a column of a table
  • 9. Drop • This command is used to remove an object(value). • We can not get the table or values in it once the table is dropped. • drop table table_name; //to drop a table
  • 10. DML(Data Manipulation Language) • These statements are used for managing the data in database. • The commands present in DDL are: Insert Update Delete Select
  • 11. Insert • This command is used to enter the records into the table. • insert into table_name values(‘value_col_1’, ‘value_col_2’); //to insert values into table
  • 12. Update • This command is used to update the value of a record or column of a table. • We use condition to know where the updation is to be made. • update table set column_name=“value” where some_column_name = “value_of_some_column”; //to update the column where it satisfies condition
  • 13. Delete • This command is used to delete the records (one or many) from a table by specifying some condition where to delete the record. • delete from table_name where column_name = “value”; //to delete record where it satisfies given condition
  • 14. select • Select command is used to retrieve the records from the table. • select column1_name, column2_name,…………. from table_name; //to select the specific columns from table • select * from table_name; // to retrieve all records present in table
  • 15. Integrity Constraints • Not Null • Unique • Primary Key • Foreign Key • Check
  • 16. Not Null • It is a constraint that ensures that every row is filled with some value for the column which has been specified as “not null”. • create table table_name (column1_name datatype NOT NULL, column2_name datatype );
  • 17. Unique • It is a constraint used for column of a table so that rows of that column should be unique. • It allows null value also. • create table table_name( column1_name datatype UNIQUE, column2_name datatype);
  • 18. Primary Key • It is a constraint used for a column of a table so that we can identify a row in a table uniquely. • create table table_name( • column1_name datatype PRIMARY KEY, • column2_name datatype);
  • 19. Foreign key • It is a constraint used to establish a relationship between two columns in the same or different tables. • For a column to be defined as a Foreign Key, it should be a defined as a Primary Key in the table which it is referring. • One or more columns can be defined as Foreign key. • This constraint identifies any column referencing the PRIMARY KEY in another table.
  • 20. SQL clauses • select • order by • from • group by • where • having • update
  • 21. Order by • This clause is used the values of a column in ascending or descending order. • select empname from emp1 order by empname;
  • 22. Group by • This clause is used to collect data across multiple records and group results by one or more columns. • select department from Student where subject1> 20 group by department;
  • 23. Having • This clause is used in combination with sql group by clause. • It is used to filter the records that a sql group by returns. • select max(subject1) from Student group by department having min(subject1)>20;
  • 24. Basic Functions • COUNT() – to count the number of records satisfy condition. • MAX()- to find the maximum value of a column of all the records present in table. • MIN()- to find the minimum value of a column of all the records present in table. • AVG()- to find the average value of a column of all the records present in table. • SUM()- to find the sum of all the values of a column in a table.
  • 25. Basic Functions • AVG()- to find the average value of a column of all the records present in table. • SUM()- to find the sum of all the values of a column in a table. • Distinct() - to find the distinct record of a table
  • 26. Joins • Join is used to retrieve data from two or more database tables. • Joins are of four types:  Cross join- This join returns the combination of each row of the first table with every column of second table.  Inner join-This join will return the rows from both the tables when it satisfies the given condition.
  • 27. Joins  Left Outer join –suppose if we have two tables. One on the left and the other on right side. When left outer join is applied on these two tables it returns all records of the left side table even if no matching rows are found in right side table  Right Outer join- it is converse of left outer join. It returns all the rows of the right side table even if no matching rows are found in left side table.
  • 28. JDBC
  • 29. JDBC • JDBC-Java Database Connectivity. • JDBC is an API that helps us to connect our java program to the database and do the manipulation of the data through java program.
  • 30. How to write a program in jdbc? • Register the Driver • Connecting to database • Create SQL statement in java • Execute SQL statements • Retrieve Result • Close Connection
  • 31. JDBC program public class JDBCProgram{ public static void main(String[] args) { try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);//REGISTERING DATABASE Connection con = DriverManager.getConnection("jdbc:odbc:dsn", "",""); //CONNECTING DATABASE Statement st=con.createStatement();//CREATE STATEMENT st.execute("create table Employee(empid integer, empname varchar(50))");//EXECUTING STATEMENT st.close();// CLOSING STATEMENT con.close();//CLOSING CONNECTION } catch (Exception err) { System.out.println( "Error: " + err ); } } }
  • 32. How to insert values into table using jdbc? • To insert the values into the table we use prepared statement. • PreparedStatement ps = con.prepareStatement("insert into Table_name(col1,col2)values(?,?)");//creating preparedstatement ps.setInt(1,value_col1);//inserting the value in column1 ps.setString(2, “value_col2”); //inserting the value in column2 ps.executeUpdate();//to execute the prepared statement
  • 33. How to update values in table using jdbc? • To update the values into the table also we use prepared statement. • PreparedStatement ps = con.prepareStatement(“update Table_name set col1=?,col2=? where col1=?);//creating preparedstatement ps.setInt(1,new_value_col1);//updating new value in column1 ps.setString(2, “value_col2”); //updating the value in column2 ps.setInt(1,old_value_col1);//getting old value of column1 ps.executeUpdate();//to execute the prepared statement
  • 34. How to delete record in table using jdbc? • To delete the record in the table also we use prepared statement. • PreparedStatement ps = con.prepareStatement(“delete from Table_name where col1=?); //creating preparedstatement ps.setInt(1,old_value_col1);//getting value of column1 ps.executeUpdate();//to execute the prepared statement
  • 35. How to retrieve record from table using jdbc? • To store the retrieved records we should use ResultSet. • ResultSet rs = st.executeQuery("select * from Employee"); //using result set to store the result while(rs.next()) { System.out.println(rs.getInt(1)); //to retrieve value of col1 System.out.println(rs.getString(2)); //to retrieve value of col2 }