0% found this document useful (0 votes)
8 views32 pages

Introduction to SQL and Databases

The document provides an introduction to databases and SQL, explaining key concepts such as data, databases, and the importance of using a database for managing large amounts of data efficiently. It covers the basics of SQL, including its syntax, types of SQL commands (DDL, DML, DCL, TCL), and various SQL operators and functions. Additionally, it outlines the structure of relational databases, the use of keys, and the installation process for Oracle Database.

Uploaded by

balbusarkabhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views32 pages

Introduction to SQL and Databases

The document provides an introduction to databases and SQL, explaining key concepts such as data, databases, and the importance of using a database for managing large amounts of data efficiently. It covers the basics of SQL, including its syntax, types of SQL commands (DDL, DML, DCL, TCL), and various SQL operators and functions. Additionally, it outlines the structure of relational databases, the use of keys, and the installation process for Oracle Database.

Uploaded by

balbusarkabhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Structured Query

Language

Quality Software Technologies


1

Introduction to Database

● What is Data?
The most simple answer: Data can be facts related
to any object in consideration

Ex.
Single Student information from College,

● What is Database?
The most simple answer: Database is a systematic
collection of data which
support storage and manipulation of data in an easy
way

Ex.
Information of Groupe of the students from College,
Telephone Directory,
2

● Why need a Database?

Here are some of the reasons why a database would be needed

● Managing a large amount of data

○ Sure, data can be stored in a spreadsheet, but if you add


large chunks of data in the sheet, might not work

○ For instance: If the size of the data increases to thousands


of records, it will simply create a problem in maintaining
and efficiency

● Accuracy

○ When doing data entry files in a spreadsheet, it becomes


difficult to manage the accuracy as there are no
validations present in it

○ Manual validation of thousands of entries and verification


are near impossible to do efficiency

● Ease of Data Upload

○ With the database, there is flexibility to update the data


as per convenience

○ Multiple people can also edit data at the same time which is a
big plus

● Data Security

○ The data is less secure in spreadsheets which makes it


easy for anyone to easily access the files and can make
changes
3

○ With databases you are provided with security groups and


privileges that you can set to restrict access

● Data Integrity

○ Data integrity is a big question when storing data


in a spreadsheet

○ Databases assure you of the accuracy and consistency of data


due to the built-in integrity checks and access controls

Introduction to DBMS
It is a Software that is used to (manage) store data permanently and retrieves a large
amount of data efficiently.

Database Management Systems were first


implemented in the 1960s

Charles Bachman’s Integrated Data Store


(IDS) is considered
the fest DBMS in history
4

Today, database technologies have evolved a lot


and correspondingly the functionalities have
increased exponentially

Introduction to SQL
SQL is the standard language for dealing with Relational Databases which can be used
to create, read, update and delete database records

SQL stands for Structured Query Language


SQL is pronounced as “See-Quel”

SQL Query
A query is a request for data or information from a database table or combination of
tables. This data may be generated as results returned by Structured Query Language
(SQL) or as pictorials, graphs, or complex results, e.g., trend analyses from data-mining
tools.
Ex. SELECT column1, column2, columnN FROM table-name WHERE [condition];

Relational Database?
“A relational database is a type of database that stores and provides access to data
points that are related to one another”
5

More about Relational Databases

● Relational databases are based on the relational model, an intuitive,


straightforward way of representing data in tables

● In a relational database, each row in the table is a record with a unique ID called
the key

● The columns of the table hold attributes of the data, and each record usually has
a value for each attribute, making it easy to establish the relationships among
data points

Term Meaning

Relation A table

Tuple A row or a record in a relation

Attribute A field or a column in a relation

Cardinality of relations The number of tuples in a station

Degree of a relation The number of attributes in a relation

Domain of an attributes The set of all values that can be taken by the attribute

Primary Key of relation An attribute or a combination of attributes that


uniquely defines each tuple in a relation

Foreign key An attribute or a combination of attributes in one


relation R1that indicates the relationship of R1 with
another relation R2.

The foreign key attributes in R1must contain values


matching those of the values in R2
6

These are the flavors of SQL

Relational Databases examples:


7

Oracle Setup and Installation


1. Log on to Windows with Administrative privileges.
2. Go to the following Web site:
[Link]
.html
3. Click Free Download and follow the instructions to select and download the
Microsoft Windows version of Oracle Database XE
4. After downloading the Oracle Database XE installation executable, [Link],
and double-click it.
5. In the Oracle Database 11g Express Edition - Install Wizard welcome window,
click Next.

6. In the License Agreement window, select I accept the terms in the license
agreement and then click Next.
8

7. In the Choose Destination Location window, either accept the default or click
Browse to select a different installation directory. (Do not select a directory that
has spaces in its name.) Then click Next.

8. In the Specify Database Passwords window, enter and confirm the password to
use for the SYS and SYSTEM database accounts. Then click Next.
9

9. In the Summary window, review the installation settings, and if you are satisfied,
click Install. Otherwise, click Back and modify the settings as necessary.

10. In the InstallShield Wizard Complete window, click Finish.


10

Datatypes
A data type specifies a particular type of data, such as integer, floating-point, Boolean,
etc.

A data type also specifies the possible values for that type, the operations that can be
performed on that
type, and the way the values of that type are stored.

1. Character Data Types

2. Numeric Data Types


11

3. Date and Time Data Types


12

Basics of SQL Tables


A table is a database object which is comprised of rows and columns in SQL
Can also be defined as a collection of related data held in a table format.

Selection

means which rows are to be returned.

Selection is the process of displaying the result using select queries.

Select queries are those queries that display particular rows to the user base on specific
condition/s.

Ex.
- Write a query to display all the information of a student named “KAVITHA”.
- SELECT * FROM STUDENT WHERE NAME="KAVITHA;
13

Applications of SQL

1. DDL [ Data Definition Language ]:

- It is used to define the database schema, create, and modify the structure of database
objects in the database.

(I) Create – It is used to create the table.

Syntax - CREATE TABLE TABLE_NAME ( COLUMN_NAME DATATYPE )

(II) Alter – It is used to alter the structure of the database.

Syntax - ALTER TABLE TABLE_NAME ADD COLUMN_NAME DATATYPE;

Syntax - ALTER TABLE TABLE_NAME DROP COLUMN COLUMN_NAME DATATYPE;

Syntax - ALTER TABLE TABLE_NAME RENAME COLUMN OLD_NAME TO NEW_NAME;

Syntax - ALTER TABLE TABLE_NAME MODIFY COLUMN_NAME DATATYPE;

(III) Drop – It is used to delete objects from the database.

Syntax - DROP TABLE TABLE_NAME;

(IV) Truncate – It is used to remove all records from a table, including all spaces

allocated for the records are removed.

Syntax - TRUNCATE TABLE TABLE_NAME;

(V) Rename – It is used to rename an object existing in the database.

Syntax - RENAME OLD_TABLE_NAME TO NEW_TABLE_NAME;


14

2. DML [ Data Manipulation Language ]:

- The SQL commands that deal with manipulating data present in the database belong
to DML.
(I) Select – It is used to retrieve data from the database.

Syntax - SELECT * FROM TABLE_NAME;

(II) Insert – It is used to insert data into a table.

Syntax - INSERT INTO TABLE_NAME VALUES (VALUE1, VALUE2);

(III) Update – It is used to update existing data within a table.

Syntax - UPDATE TABLE_NAME SET COLUMN1 = VALUE1, COLUMN2 = VALUE2


WHERE CONDITIONS;

(IV) Delete – It is used to delete records from a database table.

Syntax - DELETE FROM TABLE_NAME WHERE CONDITIONS;

3. DCL [ Data Control Language ]:

- DCL commands mainly deals with the rights, permissions, and other controls of the
database system.

(I) Grant – It gives user access privileges to the database.

(II) Revoke – It withdraws the user’s access privileges given by using the GRANT
command.

4. TCL [ Transaction Control Language ]:

- TCL commands deal with the transaction within the database.

(I) Rollback - Rollbacks a transaction in case of any error occurs.

(II) Commit - Commits a Transaction.

(III) Savepoint - Sets a savepoint within a transaction.


15

SQL Operators - Filter

WHERE Clause
We use the WHERE clause to specify conditionals in our SQL query. Where clause
can be used in the update and delete statements as well as to perform operations
on the desired data.

Rules and Usage:

1. Rules -
● When using a Where clause, we need to mention at least one
condition.

2. Usage -
● Used to query and transact the database.

● Used with an update and delete statements to make sure the right data
points are deleted.

Syntax - SELECT * FROM TABLE_NAME WHERE CONDITIONS;

Limit Clause
We use the limit clause when we have a large amount of data in the table. With the
help of the limit clause, we can restrict the number of rows our query returns.

Rules and Usage:

1. Rules -
● We need to specify a number after the limit clause.
● Float and exponential values can’t be utilized.

2. Usage -
● Used to limit the data that a query would return.

Syntax - SELECT * FROM TABLE_NAME LIMIT NUMBER;


16

Order By Clause
We use order by clause to sort data in ascending or descending order as required
by the user. By default, the data is sorted in ascending order.

Rules and Usage:

1. Rules -
● A comparable data column should be passed in the query.
● Any column can be used in the order by clause, even those which do not
appear in our select statement.
● We can sort data in ascending or descending order (by default sorting is
done in ascending order).

2. Usage -
● Order by clause is useful to get data in required sorting orders.

Syntax - SELECT * FROM TABLE_NAME ORDER BY COLUMN ASC/DESC;

Group By Clause
We use order by clause to get the summary of data in rows and is mostly taken in
usage with the aggregate functions like Count, Sum, etc.

Rules and Usage:

1. Rules:
● Columns appearing in the Select clause can only be taken care of in the
Group By clause.
● Columns we are passing to the Group By clause should be of comparable
type.

2. Usage:
● We use Group by clause to get the groups present in the data.

Syntax - SELECT * FROM TABLE_NAME WHERE CONDITION GROUP BY COLUMN;


17

SQL Operators - Logical


1. and - when both conditions are true
Syntax - SELECT * FROM TABLE_NAME WHERE 1CONDITION AND 2CONDITION;

2. or - when any one condition is true


Syntax - SELECT * FROM TABLE_NAME WHERE 1CONDITION OR 2CONDITION;

3. between - when we have to fetch data from range


Syntax - SELECT * FROM TABLE_NAME WHERE COLUMN BETWEEN CONDITION;

4. in - when we want to fetch specific data


Syntax - SELECT * FROM TABLE_NAME WHERE COLUMN IN (CONDITION);

5. like - The Like operator is used to list all rows in a table whose column
values match a specific pattern. For this purpose, we have to use the
wildcard operator.
S% - name starts with S
%S--> name ends with S
%S%--> having S
Syntax - SELECT * FROM TABLE_NAME WHERE COLUMN like %CHARECTOR;

SQL Operators - Comparison

Comparison Operators
Symbol Meaning
= Equal to

> Greater than

>= Greater than or equal to

< Less than

<= Less than or equal to

!= Not equal to
18

SQL Operators — Constraints


Constraints Operators
Not null Ensures that a column can’t have a
null value.

Unique Ensures that all values in a column


are different.

Distinct Limits values to unique values

SQL Operators — Arithmetic


Arithmetic Operators allow the user to perform arithmetic operations in SQL. The table
below shows the list of arithmetic operators available in SQL:

Arithmetic Operators
Operator Description
+ Addition

- Subtraction

* Multiplication

/ Division

Addition Syntax - SELECT COLUMN_NAME + 100 FROM TABLE_NAME;

Subtraction Syntax - SELECT COLUMN_NAME - 100 FROM TABLE_NAME;

Multiplication Syntax - SELECT COLUMN_NAME * 100 FROM TABLE_NAME;

Division Syntax - SELECT COLUMN_NAME / 30, COLUMN_NAME / 30/90 FROM


TABLE_NAME;
19

SQL UNION
● Used to combine the result-set of two or more SELECT statements removing
duplicates
● Each SELECT statement within the UNION must have the same number of
columns
● The selected columns must be of similar data types and must be in the same
order in each SELECT statement

Syntax - SELECT COLUMN_NAME1 FROM TABLE_NAME1 UNION SELECT


COLUMN_NAME2 FROM TABLE_NAME2;

SQL UNION ALL


● Used to combine the results of two SELECT statements including duplicate rows.
● The same rules that apply to the UNION clause will apply to the UNION ALL
operator.

Syntax - SELECT COLUMN_NAME1 FROM TABLE_NAME1 UNION ALL SELECT


COLUMN_NAME2 FROM TABLE_NAME2;

Case Sensitivity in SQL


The SQL Keywords are case-insensitive (SELECT, FROM, WHERE, AS, ORDER BY,
HAVING, GROUP BY, etc), but are usually written in all capitals.

1. Keywords IN SQL IS NOT CASE-SENSITIVE.


2. TABLE NAMES IN SQL ARE NOT CASE SENSITIVE.
3. COLUMN NAMES IN SQL ARE NOT CASE SENSITIVE.
4. DATA IN SQL IS CASE SENSITIVE
20

Keys in SQL
A database consist of multiple tables and these tables and their contents are related to
each other by some relations/conditions. To uniquely identify each row of these tables,
we use SQL keys. A SQL key can be a single column or a group of columns used to
identify the rows of a table uniquely. SQL keys are a means to ensure that no row will
have duplicate values. They are also a means to establish relations between multiple
tables in a database.

1. Primary Key
Properties:
● Only a single primary key for a table. (A special case is a composite key, which
can be formed by the composition of 2 or more columns, and act as a single
candidate key.)
● The primary key column cannot have any NULL values.
● The primary key must be unique for each row.

Syntax -

CREATE TABLE TABLE_NAME (


COLUMN_NAME DATATYPE,
PRIMARY KEY (COLUMN_NAME)
);

2. Foreign Key:
Foreign keys are keys that reference the primary keys of some other table. They
establish a relationship between 2 tables and link them up.

Syntax -

CREATE TABLE TABLE_NAME2(


FOREIGN KEY (COLUMN_NAME)
REFERENCES TABLE_NAME1(COLUMN_NAME)
);
21

SQL Functions — Aggregations


Aggregations Functions
Avg ( ) The AVG( ) function returns the average value of a
numeric column.

Count ( ) The COUNT( ) function returns the number of rows that


matches a specified criterion.

Sum ( ) The SUM( ) function returns the total sum of a numeric


column.

Max ( ) The MAX( ) function returns the largest value of the


selected column.

Min ( ) The MIN( ) function returns the smallest value of the


selected column.

Avg ( ) Syntax - SELECT AVG(COLUMN_NAME) FROM TABLE_NAME WHERE


CONDITIONS;

Count ( ) Syntax - SELECT COUNT(COLUMN_NAME) FROM TABLE_NAME WHERE


CONDITIONS;

Sum ( ) Syntax - SELECT SUM(COLUMN_NAME) FROM TABLE_NAME WHERE


CONDITIONS;

Min ( ) Syntax - SELECT MIN(COLUMN_NAME) FROM TABLE_NAME WHERE


CONDITIONS;

Max ( ) Syntax - SELECT MAX(COLUMN_NAME) FROM TABLE_NAME WHERE


CONDITIONS;
22

SQL Functions — Date & Time Functions

Name Description
ADDDATE() Add time values (intervals) to a date value

ADDTIME() Add time

CONVERT_TZ() Convert from one time zone to another

CURDATE() Return the current date


CURRENT_DATE(),
Synonyms for CURDATE()
CURRENT_DATE
CURRENT_TIME(),
Synonyms for CURTIME()
CURRENT_TIME
CURRENT_TIMESTAMP()
Synonyms for NOW()
, CURRENT_TIMESTAMP
CURTIME() Return the current time
Extract the date part of a date or datetime
DATE()
expression
DATE_ADD() Add time values (intervals) to a date value
DATE_FORMAT() Format date as specified
DATE_SUB() Subtract a time value (interval) from a date
DATEDIFF() Subtract two dates
DAY() Synonym for DAYOFMONTH()
DAYNAME() Return the name of the weekday
DAYOFMONTH() Return the day of the month (0-31)
DAYOFWEEK() Return the weekday index of the argument
DAYOFYEAR() Return the day of the year (1-366)
EXTRACT() Extract part of a date
FROM_DAYS() Convert a day number to a date
FROM_UNIXTIME() Format Unix timestamp as a date
GET_FORMAT() Return a date format string
HOUR() Extract the hour
23

Return the last day of the month for the


LAST_DAY
argument
LOCALTIMESTAMP,
Synonym for NOW()
LOCALTIMESTAMP()
MAKEDATE() Create a date from the year and day of year
MAKETIME() Create time from hour, minute, second
MICROSECOND() Return the microseconds from argument
MINUTE() Return the minute from the argument
MONTH() Return the month from the date passed
MONTHNAME() Return the name of the month
NOW() Return the current date and time
PERIOD_ADD() Add a period to a year-month

PERIOD_DIFF() Return the number of months between periods

QUARTER() Return the quarter from a date argument


SEC_TO_TIME() Converts seconds to 'hh:mm:ss' format
SECOND() Return the second (0-59)
STR_TO_DATE() Convert a string to a date
Synonym for DATE_SUB() when invoked with
SUBDATE()
three arguments
SUBTIME() Subtract times

SYSDATE() Return the time at which the function executes

TIME() Extract the time portion of the expression passed

TIME_FORMAT() Format as time


TIME_TO_SEC() Return the argument converted to seconds
TIMEDIFF() Subtract time
With a single argument, this function returns the
TIMESTAMP() date or datetime expression; with two
arguments, the sum of the arguments
24

TIMESTAMPADD() Add an interval to a datetime expression

TIMESTAMPDIFF() Subtract an interval from a datetime expression

TO_DAYS() Return the date argument converted to days

Return the date or datetime argument converted


TO_SECONDS()
to seconds since Year 0

UNIX_TIMESTAMP() Return a Unix timestamp

UTC_DATE() Return the current UTC date

UTC_TIME() Return the current UTC time

UTC_TIMESTAMP() Return the current UTC date and time

WEEK() Return the week number

WEEKDAY() Return the weekday index

WEEKOFYEAR() Return the calendar week of the date (1-53)

YEAR() Return the year

YEARWEEK() Return the year and week


25

CURDATE ( ) / CURRENT_DATE ( ) / CURRENT_DATE


Syntax - SELECT CURDATE ( ) / CURRENT_DATE ( ) / CURRENT_DATE;

DATE ( ) Syntax - SELECT DATE ( COLUMN_NAME ) FROM TABLE_NAME;

DAY ( ) Syntax - SELECT DAY ( COLUMN_NAME ) FROM TABLE_NAME;

DAYNAME ( ) Syntax - SELECT DAYNAME ( COLUMN_NAME ) FROM TABLE_NAME;


MONTH ( ) Syntax - SELECT MONTH ( COLUMN_NAME ) FROM TABLE_NAME;

MONTHNAME ( ) Syntax - SELECT MONTHNAME ( COLUMN_NAME ) FROM


TABLE_NAME;

YEAR ( ) Syntax - SELECT YEAR ( COLUMN_NAME ) FROM TABLE_NAME;

DAYOFWEEK ( ) Syntax - SELECT DAYOFWEEK ( COLUMN_NAME ) FROM


TABLE_NAME;

DAYOFMONTH ( ) Syntax - SELECT DAYOFMONTH ( COLUMN_NAME ) FROM


TABLE_NAME;

DAYOFYEAR ( ) Syntax - SELECT DAYOFYEAR ( COLUMN_NAME ) FROM


TABLE_NAME;

NOW ( ) Syntax - SELECT NOW( );

SYSDATE ( ) Syntax - SELECT SYSDATE( );


26

Single-Row Functions
Single row functions are the one who works on a single row and returns one output
per row. For example, length and case conversion functions are single-row functions.

1. Case Conversion functions


Accept character input and return a character value. Functions under the category are
UPPER, LOWER, and INITCAP.
● UPPER function converts a string to upper case.
● LOWER function converts a string to lowercase.
● INITCAP function converts only the initial alphabets of a string to upper case.

Syntax - SELECT UPPER (COLUMN_NAME), INITCAP(COLUMN_NAME), LOWER


(COLUMN_NAME) FROM TABLE_NAME WHERE CONDITIONS;

2. Character functions
Accept character input and return a number or character value. Functions under the
category are CONCAT, LENGTH, SUBSTR, INSTR, LPAD, RPAD, TRIM, and REPLACE.
● CONCAT function concatenates two string values.
Syntax - SELECT CONCAT(COLUMN_NAME1, COLUMN_NAME2) FROM TABLE_NAME
WHERE CONDITIONS;
● LENGTH function returns the length of the input string.
Syntax - SELECT LENGTH(COLUMN_NAME1, COLUMN_NAME2) FROM TABLE_NAME
WHERE CONDITIONS;
● SUBSTR function returns a portion of a string from a given start point to an
endpoint.
Syntax - SELECT SUBSTR (COLUMN_NAME, 1, 5) FROM TABLE_NAME WHERE
CONDITIONS;
● INSTR function returns the numeric position of a character or a string in a given
string.
Syntax - SELECT INSTR (COLUMN_NAME, ‘CHARACTER’) FROM TABLE_NAME WHERE
CONDITIONS;
27

● LPAD and RPAD functions pad the given string up to a specific length with a
given character.
Syntax - SELECT RPAD (COLUMN_NAME, 10, '_' ) ||
LPAD (COLUMN_NAME, 10, '_' ) FROM TABLE_NAME WHERE CONDITIONS;
● TRIM function trims the string input from the start or end.
○ If you specify LEADING, then Oracle Database removes any leading characters equal
to trim_character.
○ If you specify TRAILING, then Oracle removes any trailing characters equal to
trim_character.
○ If you specify BOTH or none of the three, then Oracle removes leading and trailing
characters equal to trim_character.

Syntax - SELECT TO_CHAR (TRIM (LEADING ‘CHARACTER’ FROM COLUMN_NAME)


FROM TABLE_NAME;
● REPLACE function replaces characters from the input string with a given
character.
Syntax - SELECT COLUMN_NAME, REPLACE (COLUMN_NAME, SEARCH_STR,
REPLACE_STR) REPLACED FROM TABLE_NAME;

3. Number functions
Accept numeric input and return numeric values. Functions under the category are
ROUND, TRUNC, and MOD.
● ROUND and TRUNC functions are used to round and truncate the number value.
Syntax - SELECT ROUND (1372.472,1) FROM TABLE_NAME;
Syntax - SELECT TRUNC (72183,-2) FROM TABLE_NAME;
● MOD is used to return the remainder of the division operation between two
numbers.
Syntax - SELECT MOD (5641,2) FROM TABLE_NAME;
28

SQL Sub Query


Subqueries are the queries inside a query. Subqueries can be made using WHERE,
FROM, or SELECT clauses.
Syntax - SELECT COLUMN_NAME FROM TABLE_NAME1 WHERE CONDITION ( SELECT
COLUMN_NAME FROM TABLE_NAME2 FROM TABLE_NAME WHERE CONDITIONS )

SQL JOINS
JOINS in SQL are commands which are used to combine rows from two or more tables,
based on a related column
between those tables. They are predominantly used when a user is trying to extract
data from tables that have one-to-many or many-to-many relationships between
them.
29

1. INNER JOIN -
This type of join returns those records which have matching values in both
tables. So, if you perform an INNER JOIN operation between the Employee table
and the Projects table, all the tuples which have matching values in both the
tables will be given as output.

Syntax -
SELECT TABLE_NAME1.COLUMN_NAME1, TABLE_NAME1.COLUMN_NAME2,
TABLE_NAME2.COLUMN_NAME1,....
FROM TABLE_NAME1
INNER JOIN TABLE_NAME2
ON TABLE_NAME1.MATCHIN_COLUMN = TABLE_NAME2.MATCHIN_COLUMN;

2. LEFT JOIN
The Left join or the LEFT OUTER JOIN returns all the records from the left table and also
those records which satisfy a condition from the right table. Also for the records having no
matching values in the right table, the output or the result set will contain the null values.

Syntax -
SELECT TABLE_NAME1.COLUMN_NAME1, TABLE_NAME1.COLUMN_NAME2,
TABLE_NAME2.COLUMN_NAME1,....
FROM TABLE_NAME1
LEFT JOIN TABLE_NAME2
ON TABLE_NAME1.MATCHIN_COLUMN = TABLE_NAME2.MATCHIN_COLUMN;
30

3. RIGHT JOIN
The RIGHT JOIN or the RIGHT OUTER JOIN returns all the records from the right
table and also those records which satisfy a condition from the left table. Also for the
records having no matching values in the left table, the output or the result set will contain
the NULL values.

Syntax -
SELECT TABLE_NAME1.COLUMN_NAME1, TABLE_NAME1.COLUMN_NAME2,
TABLE_NAME2.COLUMN_NAME1,....
FROM TABLE_NAME1
RIGHT JOIN TABLE_NAME2
ON TABLE_NAME1.MATCHIN_COLUMN = TABLE_NAME2.MATCHIN_COLUMN;
31

4. FULL JOIN
Full Join or the Full Outer Join returns all those records that either have a
match in the left(Table?) or the right(Table2) table.

Syntax -
SELECT TABLE_NAME1.COLUMN_NAME1, TABLE_NAME1.COLUMN_NAME2,
TABLE_NAME2.COLUMN_NAME1,....
FROM TABLE_NAME1
FULL JOIN TABLE_NAME2
ON TABLE_NAME1.MATCHIN_COLUMN = TABLE_NAME2.MATCHIN_COLUMN;

SQL TRIGGER
Triggers are the SQL codes that are automatically executed in response to certain events
on a particular table. These are used to maintain the integrity of the data.

Syntax -
Create Trigger Trigger_Name
(Before | After)
[ Insert | Update | Delete ]
on [ Table Name ]
[ for each row ]
[ Trigger_body ]

You might also like