Professional Documents
Culture Documents
Structured Query Language
Structured Query Language
Structured Query Language
TO
SQL
Structured Query Language
Business need Database
The first Relational database was released by Relational Software later becoming
Oracle.
CONCEPT OF SQL
The user specifies a certain condition.
The program will go through all the records in the database file and select those records that
satisfy the condition.
Table
Rows
Keys
Primary Key
Primary Keys are how every row in the table is searchable.
They can be a single column or a combination of columns that
make up a unique identification number.
Foreign Key
Foreign Keys are used to link tables together within a database.
These links are called relationships.
r y key
a
Prim
101 JAVA 9
Tuple 101 JAVA 9
102 AMQ 9
Relation
Cardinality
103 SQL 2
104 GROOVY 2
Attributes
Degree
SQL COMMANDS
Example Query:
This query will create a table named Students with three columns, ROLL_NO, NAME and SUBJECT.
Restriction:
You cannot truncate the table if it is linked with another table
Syntax:
TRUNCATE TABLE<Table_name>;
Example:
TRUNCATE TABLE Customer;
DROP
Syntax:
DROP TABLE<Table_name>;
Example:
DROP TABLE Customer;
TRUNCATE VS DROP
SELECT
Example:
Deletion is not possible if the row to be deleted is referred in the child table.
Deletion of the parent record is made possible by using a foreign key reference option.
DELETE VS TRUNCATE
Cannot be reverted.
Reverting the data is performed using Reverting the data until the check point
ROLLBACK. is done by save point.
DATABASE TRANSACTION
COMMIT Ends the current transaction by making all pending data changes permanent.
ROLLBACK TO This rolls back the current transaction to the specified savepoint, thereby discarding any
Savepoint_name
changes or savepoints created after the savepoint to which you are rolling back.
BASIC STRUCTURE OF A SQL QUERY
COMPOSITION IN,BETWEEN,LIKE,”%_”
UNION UNION