TCL COMMANDS



TABLE CREATION:

SQL>CREATE  TABLE  students(s_id number(10),s_name varchar(15),s_dob date,
status varchar(10) );

Table created.

INSERTION:

SQL>INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
Enter value for s_id:5025
Enter value for s_name: John
Enter the value for s_dob:14-jul-88
Enter value for status: distinction
Old 1: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 1:INSERT INTO students values(5025,’John’,25-jul-89, ‘distinction’)

1 row created.

SQL>/
Enter value for s_id:5032
Enter value for s_name: Jithin
Enter the value for s_dob:27-nov-89
Enter value for status: first
Old 2: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 2:INSERT INTO students values(5032,’Jithin’,27-nov-89, ‘first’)

1 row created.

SQL>/
Enter value for s_id:5033
Enter value for s_name: Midhun
 Enter the value for s_dob:02-dec-89
Enter value for status: first
Old 3: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 3:INSERT INTO students values(5016,’Midhun’, 02-dec-89, ‘first’)

1 row created.

COMMIT:

SQL>COMMIT

Commit complete.

SQL>SELECT *  from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

ROLLBACK:

SQL>INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
Enter value for s_id:5047
Enter value for s_name:Stephen
Enter the value for s_dob:23-aug-89
Enter value for status: distinction
Old 1: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 1:INSERT INTO students values(5056,’Stephen’,23-aug-89, ‘distinction’)

1 row created.

SQL>SELECT *  from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5047        Stephen             23-aug-89         Distinction

SQL>ROLLBACK;

Rollback complete.

SQL>SELECT *  from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

SAVEPOINT:

SQL>INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
Enter value for s_id:5001
Enter value for s_name: Aswin
Enter the value for s_dob:19-jan-89
Enter value for status: first
Old 1: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 1:INSERT INTO students values(5056,’aswin’,19-jan-89, ‘first’)

1 row created.

SQL>/
Enter value for s_id:5047
Enter value for s_name:Stephen
Enter the value for s_dob:23-aug-89
Enter value for status: distinction
Old 2: INSERT INTO student
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 2:INSERT INTO students values(5056,’Stephen’,23-aug-89, ‘distinction’)

1 row created.

SQL>SELECT * from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5047        Stephen             23-aug-89         Distinction
5001        Aswin              19-jan-89          First

SQL>SAVEPOINT students;

Savepoint created.

SQL>SELECT *  from students;
S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5047        Stephen             23-aug-89         Distinction
5001        Aswin              19-jan-89          First

ROLLBACK TO SAVEPOINT:

SQL>INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
Enter value for s_id:5045
Enter value for s_name:Karthee
Enter the value for s_dob:30-jul-90
Enter value for status: first
Old 1: INSERT INTO students
Values(&s_id,’&s_name’,&s_dob,’&status’);
New 1:INSERT INTO students values(5045,’Karthee’,30-jul-90, ‘first’)

1 row created.

SQL>SELECT *  from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5047        Stephen             23-aug-89         Distinction
5001        Aswin              19-jan-89          First
5045        Karthee            30-jul-89           First

6 rows selected.

SQL>ROLLBACK TO SAVEPOINT students;

Rollback complete.

SQL>SELECT * from students;

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5025         John        14-jul-88       Distinction
5032         Jithin              27-nov-89      First
5033         Midhun   13-jun-89       First

S_ID        S_NAME         S_DOB         STATUS
----------------------------------------------------------------
5047        Stephen             23-aug-89         Distinction
5001        Aswin              19-jan-89          First

Previous
Next Post »

Still not found what you are looking for? Try again here.