Oracle 增加修改刪除欄位/新增記錄
阿新 • • 發佈:2019-01-04
新增記錄
新增記錄語法:
--新增記錄(仿照已有表記錄)
INSERT INTO T_XXXX T
(T.FIELD_1, T.FIELD_2, T.FIELD_3, T.FIELD_4, T.FIELD_5)
SELECT T2.FIELD_1, T2.FIELD_2, T2.FIELD_3, T2.FIELD_4, T2.FIELD_5
FROM T_YYYY T2
WHERE T2.FIELD_1 = 'DEMO';
--新增記錄(自定義值)
INSERT INTO T_XXXX T
(T.FIELD_1, T.FIELD_2, T.FIELD_3, T.FIELD_4, T.FIELD_5)
VALUES
(10000, 10000, 'DEMO', 'DEMO', SYSDATE);
####################淺淺的分割線####################
更新語法示例:
--更新記錄(自定義值)
UPDATE T_XXXX T
SET T.FIELD_1 = 'DEMO', T.FIELD_2 = 'DEMO'
WHERE T.FIELD_3 = '10000';
--更新記錄(仿照已有表記錄)
UPDATE T_XXXX T
SET (T.FIELD_1, T.FIELD_2) = (SELECT T2.FIELD_1, T2.FIELD_2
FROM T_YYYY T2
WHERE T2.FIELD_3 = '10000')
WHERE T.FIELD_3 = '10000';