在Oracle數據庫中,可以使用以下方式來給變量賦值:
DECLARE
v_name VARCHAR2(50);
BEGIN
SELECT name INTO v_name FROM employees WHERE id = 1;
DBMS_OUTPUT.PUT_LINE('Employee name is ' || v_name);
END;
DECLARE
v_salary NUMBER := 5000;
BEGIN
DBMS_OUTPUT.PUT_LINE('Employee salary is ' || v_salary);
END;
DECLARE
v_total_sal NUMBER;
BEGIN
SELECT SUM(salary) INTO v_total_sal FROM employees;
DBMS_OUTPUT.PUT_LINE('Total salary of all employees is ' || v_total_sal);
END;
這些是一些基本的賦值操作,在Oracle數據庫中可以使用的方式。