Command: Alter
Command: Alter
ALTER command
alter command is used for altering the table structure, such as,
TRUNCATE command
TRUNCATE TABLE student;
DROP command
DROP TABLE student;
RENAME query
RENAME TABLE student to students_info;
INSERT command
INSERT INTO table_name VALUES(data1, data2, ...)
UPDATE command
UPDATE student SET age=18 WHERE student_id=102;
DELETE command
COMMIT command
COMMIT;
ROLLBACK command
ROLLBACK TO savepoint_name;
SAVEPOINT command
SAVEPOINT savepoint_name;
id name
1 Abhi
2 Adam
4 Alex
Lets use some SQL queries on the above table and see the results.
INSERT INTO class VALUES(5, 'Rahul');
COMMIT;
SAVEPOINT A;
SAVEPOINT B;
SAVEPOINT C;
NOTE: SELECT statement is used to show the data stored in the table.
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
6 Chris
7 Bravo
Now let's use the ROLLBACK command to roll back the state of data to the savepoint B.
ROLLBACK TO B;
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
6 Chris
Now let's again use the ROLLBACK command to roll back the state of data to the savepoint A
ROLLBACK TO A;
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
OR operator
SELECT * FROM Emp WHERE salary > 10000 OR age > 25