On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Types of Keys in Database• Primary key• Foreign key• Compound key
Types of Table RelationshipsA relationship works by matching data in key columns — usually columnswith the same name in both tables. In most cases, the relationship matchesthe primary key from one table, which provides a unique identifier for eachrow, with an entry in the foreign key in the other table.• One-to-Many Relationships• Many-to-Many Relationships• One-to-One Relationships
Structured Query LanguageSQL (Structured Query Language)A special purpose programming language designedfor managing data in relational database managementsystems (RDBMS).
SQL Command Types• Data Definition Language (DDL)• Data Manipulation Language (DML)• Data Control Language (DCL)• Transaction Control Language (TCL)
Data Definition LanguageData Definition Language (DDL) statements are used to define thedatabase structure or schema. Some examples:– CREATE - to create objects in the database– ALTER - alters the structure of the database– DROP - delete objects from the database– TRUNCATE - remove all records from a table, including allspaces allocated for the records are removed– COMMENT - add comments to the data dictionary– RENAME - rename an object
Data Manipulation LanguageData Manipulation Language (DML) statements are used formanaging data within schema objects. Some examples: SELECT - retrieve data from the a database INSERT - insert data into a table UPDATE - updates existing data within a table DELETE - deletes all records from a table, the space for therecords remain MERGE - UPSERT operation (insert or update) CALL - call a PL/SQL or Java subprogram EXPLAIN PLAN - explain access path to data LOCK TABLE - control concurrency
Data Control LanguageData Control Language (DCL) statements. Someexamples:– GRANT - gives users access privileges to database– REVOKE - withdraw access privileges given withthe GRANT command
Transaction Control LanguageTransaction Control Language (TCL) statements are used to managethe changes made by DML statements. It allows statements to begrouped together into logical transactions.– COMMIT - save work done– SAVEPOINT - identify a point in a transaction to which you canlater roll back– ROLLBACK - restore database to original since the lastCOMMIT– SET TRANSACTION - Change transaction options likeisolation level and what rollback segment to use
SQL SelectSELECT [ALL | DISTINCT] columnname1[,columnname2] FROM tablename1[,tablename2] [WHERE condition][ and|or condition...][GROUP BY column-list] [HAVING conditions][ORDER BY column-list [ASC | DESC] ]