Types of database systems and SQL
Types of database systems and SQL
SELECT *
FROM EmployTable
USING DELETE in SQL STATEMENT
Used to delete entire Record in a table
• DELETE FROM Table Name
• WHERE Condition ;
Example
• DELETE FROM Customers
• WHERE CustomerName='Alfreds Futterkiste';
USING UPDATE in SQL STATEMENT
Used to change value of a field (attribute) in a record
• UPDATE table_name
SET field1 = value1, field2 = value2, ...
WHERE condition;
Example
• UPDATE StudentTable
• SET studentTelephone = 0999837444, program = ICT
• WHERE StudentID = 2001xx6
USING INSERT in SQL STATEMENT
Used to Add a new record in a table
• INSERT INTO table_name (field1, field2, field2,
...)VALUES (value1, value2, value3, ...);
Example
INSERT INTO StudentTable ( Fname, Sname, Age, Program),
VALUES (Mary, Banda, 23, Computers)
USING JOIN in SQL STATEMENT
The SQL Joins clause is used to combine records from two or more
tables in a database.
• There are various types of Joins provided by SQL which are
categorized based on the way data across multiple tables are joined
together.
• Inner Join − An Inner Join retrieves the intersection of two tables. It compares
each row of the first table with each row of the second table. If the pairs of
these rows satisfy the join-predicate, they are joined together. This is a
default join.
• Outer Join − An Outer Join retrieves all the records in two tables even if there
is no counterpart row of one table in another table, like Inner Join. Outer join
is further divided into three subtypes:
• Left Join,
• Right Join
• Full Join.
USING JOIN in SQL STATEMENT
Since Inner Join is default we don’t mention it.
SELECT custID, Fname, Sname, Amount
FROM Customers , Orders
JOIN Orders ON Customer.CustID = Orders.CustID;
This is an INNER JOIN, Since Inner Join is default we don’t mention it.