以下是一些Oracle數據庫增刪改查的例題:
例題1:
假設有一個名為employees
的表,結構如下:
CREATE TABLE employees (
id NUMBER PRIMARY KEY,
name VARCHAR2(50),
age NUMBER,
department VARCHAR2(50)
);
INSERT INTO employees (id, name, age, department) VALUES (1, 'John Doe', 30, 'HR');
SELECT * FROM employees;
SELECT * FROM employees WHERE age >= 30;
UPDATE employees SET department = 'IT' WHERE department = 'HR';
DELETE FROM employees WHERE id = 2;
例題2:
假設有一個名為products
的表,結構如下:
CREATE TABLE products (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
price NUMBER,
quantity NUMBER
);
INSERT INTO products (id, name, price, quantity) VALUES (1, 'Laptop', 1000, 50);
SELECT price FROM products;
SELECT * FROM products WHERE price > 500;
UPDATE products SET quantity = 100 WHERE quantity = 50;
DELETE FROM products WHERE id = 1;
這些例題涵蓋了Oracle數據庫的基本增刪改查操作。通過練習這些題目,可以加深對Oracle數據庫的理解和掌握。