Presentation is loading. Please wait.

Presentation is loading. Please wait.

HAVING,INDEX,COMMIT & ROLLBACK

Similar presentations


Presentation on theme: "HAVING,INDEX,COMMIT & ROLLBACK"— Presentation transcript:

1 HAVING,INDEX,COMMIT & ROLLBACK
SQL CLAUSES

2 WHAT IS INDEX? Indexes help us retrieve data from tables quicker.
Tables can have millions of rows but usually only a subset of those rows is needed to work on. This is where the concept of an index comes from. With an index, it reads the index table, find where that row is held and then fetches it- much faster!

3 CREATE INDEX Syntax Creates an index on a table. Duplicate values are allowed: CREATE INDEX index_name ON table_name; //BASIC SYNTAX SYNTAX TWO CREATE INDEX index_name ON table_name (column1, column2, ...);

4 HAVING CLAUSE HAVING filters records that work on summarized GROUP BY results. HAVING applies to summarized group records, whereas WHERE applies to individual records. Only the groups that meet the HAVING criteria will be returned. HAVING requires that a GROUP BY clause is present. WHERE and HAVING can be in the same query.

5 Syntax FOR HAVING SELECT column-names FROM table-name WHERE condition
GROUP BY column-names HAVING condition

6 COMMIT AND ROLLBACK The following commands are used to control transactions. COMMIT − to save the changes. ROLLBACK − to roll back the changes.(UNDO)

7 The COMMIT Command The COMMIT command is the transactional command used to save changes invoked by a transaction to the database. The COMMIT command saves all the transactions to the database since the last COMMIT or ROLLBACK command.

8 The syntax for the COMMIT command
SQL> DELETE FROM TABLE_NAME WHERE COLUMN_NAME = VALUE; SQL> COMMIT; THIS A SYNTAX which would delete those records from the table which have SPECIFIED COLUMN_NAME = VALUE and then COMMIT the changes in the database.

9 The ROLLBACK Command The ROLLBACK command is the transactional command used to undo transactions that have not already been saved to the database. This command can only be used to undo transactions since the last COMMIT or ROLLBACK command was issued.

10 The syntax for a ROLLBACK command
SQL> DELETE FROM TABLE_NAME WHERE COLUMN_NAME = VALUE; SQL> ROLLBACK; THIS A SYNTAX which would delete those records from the table which have the COLUMN_NAME = VALUE and then ROLLBACK the changes in the database.

11 END OF SLIDE


Download ppt "HAVING,INDEX,COMMIT & ROLLBACK"

Similar presentations


Ads by Google