📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 204question

STRUCTURED QUERY LANGUAGE (SQL) · Part 16

Chapter 2: 3 · COMPUTER SCIENCE

- - Structured Query Language SELECT Gender, count(*) FROM Student GROUP BY Gender; Gender count(*) M F The * is used with the COUNT to include the NULL values. Note The GROUP BY applies the aggregate functions independently to a series of groups that are defined by having a field value in common. The output of the above SELECT statement gives a count of the number of Male and Female students. .

. . HAVING clause The HAVING clause can be used along with GROUP BY clause in the SELECT statement to place condition on groups and can include aggregate functions on them. For example to count the number of students belonging to chennai.

SELECT Place , count(*) FROM Student GROUP BY Place HAVING place = ‘Chennai’; Place count Chennai The above output shows the no. of students belongs to chennai. . .

TCL commands . . . COMMIT command The COMMIT command is used to permanently save any transaction to the database.

When any DML commands like INSERT, UPDATE, DELETE commands are used, the changes made by these commands are not permanent. It is marked permanent only after the COMMIT command is given from the SQL prompt. Once the COMMIT command is given, the changes made cannot be rolled back. The COMMIT command is used as COMMIT; .

. . ROLLBACK command The ROLLBACK command restores the database to the last commited state. It is used with SAVEPOINT command to jump to a particular savepoint location.

The syntax for the ROLLBACK command is : ROLL BACK TO save point name; 12th Computer Chapter - - . . . SAVEPOINT command The SAVEPOINT command is used to temporarily save a transaction so that you can rollback to the point whenever required.

The different states of our table can be saved at anytime using different names and the rollback to that state can be done using the ROLLBACK command. SAVEPOINT ; Example showing COMMIT, SAVEPOINT and ROLLBACK in the student table having the following data: Admno Name Gender Age Place Revathi F Chennai Devika F Bangalore

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →