To answer this question, let's go through each statement and understand its effect on the table:
create table temp (name varchar2(20), empid integer);
- This statement creates a table called "temp" with two columns: "name" of type varchar2 with a maximum length of 20 characters, and "empid" of type integer.
insert into temp ('abc', 100);
- This statement attempts to insert a row into the "temp" table with the values 'abc' for the "name" column and 100 for the "empid" column. However, the syntax of the insert statement is incorrect. The correct syntax should be insert into temp (name, empid) values ('abc', 100);
.
savepoint a;
- This statement creates a savepoint named "a" in the current transaction. A savepoint allows you to roll back the transaction to a specific point in time.
insert into temp ('def', 100);
- This statement attempts to insert another row into the "temp" table with the values 'def' for the "name" column and 100 for the "empid" column. However, since the previous insert statement had a syntax error, it would have resulted in an error and no rows would have been inserted.
delete from temp;
- This statement deletes all rows from the "temp" table.
rollback to a;
- This statement rolls back the transaction to the savepoint "a", which was created after the first incorrect insert statement. This means that any changes made after the savepoint will be undone.
commit;
- This statement commits the transaction, making all changes permanent. However, since the rollback statement was executed before the commit statement, the changes made after the savepoint "a" were rolled back. Therefore, no rows are inserted into the "temp" table.
Based on the above analysis, the correct answer is D. 1, as only one row was successfully inserted into the "temp" table before the rollback statement.