SQLPLUS执行一个脚本文件的相关命令:
save/get/start/@/spool out
SQLPLUS中,在运行时指定一个变量,甚至是条件,使用&:
SQL> SELECT id, last_name, salary
2 FROM s_emp
3 WHERE dept_id = &department_number;
SQL> SELECT id, &column_name
2 FROM s_ord
3 WHERE &condition;
To specifiy value at runtime in sqlplus, you can use either define or accept:
syntax of define:
DEFINE variable = value Creates a CHAR datatype user variable and assigns
a value to it.
DEFINE variable Displays the variable, its value, and its datatype.
DEFINE Displays all user variables with value and datatype.
syntax of accept:
SET ECHO OFF
ACCEPT p_dname PROMPT ’Provide the department name: ’
SELECT d.name, r.id, r.name ”REGION NAME”
FROM s_dept d, s_region r
WHERE d.region_id = r.id
AND UPPER(d.name) LIKE UPPER(’%&p_dname%’)
SET ECHO ON
a value can be undefined:
UNDEFINE dname
Passing a variable into a script naming l7param.sql and execute:
SQL> START l7param President