1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| CREATE TABLE employees (ID NUMBER, NAME VARCHAR2(100),
salary NUMBER,
fee NUMBER GENERATED ALWAYS AS (salary*0.03) VIRTUAL
)
INSERT INTO employees (ID, NAME, salary) VALUES (1, 'George', 1000);
INSERT INTO employees (ID, NAME, salary) VALUES (2, 'Tom', 1500);
INSERT INTO employees (ID, NAME, salary) VALUES (3, 'Michael', 1200);
INSERT INTO employees (ID, NAME, salary) VALUES (4, 'Steven', 1100);
SELECT * FROM employees
ALTER TABLE employees ADD new_fee NUMBER
UPDATE employees SET new_fee = fee
ALTER TABLE employees DROP COLUMN fee
SELECT * FROM employees |
Partager