....

2015年1月6日 星期二

[長知識] Oracle SQL Manipulating Data (控制資料)

把如何控制資料的語法分做幾類

1. 新增 insert into

insert into departments(id, name, t_id, t_name) values (007, Ken, 100, King);

2. 修改 update
update employees set id=008 where t_name=100;


3. 刪除 delete from
delete from departments where t_name=King;

4.清除 truncate table (速度快,但無法 rollback)
truncate table departments;

5. 確認 commit
commit;

6. 取消 rollback
rollback;

7. savepoint (設立停損點)
搭配 rollback 可以先部分 rollback, 不可搭配 commit

8. read consistence (讀取一致) 此為Oracle特有
讀取不影響修改,修改不影響讀取,因為undo data (rollback data)



對於各個語法做英文的敘述可能更為清楚明瞭

INSERT - adds a new row to the table
UPDATE - modifies existing rows in the table
DELETE - removes existing rows from the table
COMMIT - makes all pending changes permanent
SAVEPOINT - is used to roll back to the savepoint marker
ROLLBACK - discards all pending data changes

沒有留言:

張貼留言