在单&的情况中,每次执行sql,oracle都要提示用户输入值,然后执行,在双&中,只需用户输入一次值,以后的每次运行都会使用第一次输入的值
SQL> select * from employees where employee_id=&id;
输入 id 的值: 205原值 1: select * from employees where employee_id=&id
新值 1: select * from employees where employee_id=205
EMPLOYEE_ID FIRST_NAME
----------- ----------------------------------------
LAST_NAME
--------------------------------------------------
--------------------------------------------------
PHONE_NUMBER HIRE_DATE JOB_ID
---------------------------------------- -------------- --------------------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
205 Shelley
Higgins
SHIGGINS
EMPLOYEE_ID FIRST_NAME
----------- ----------------------------------------
LAST_NAME
--------------------------------------------------
--------------------------------------------------
PHONE_NUMBER HIRE_DATE JOB_ID
---------------------------------------- -------------- --------------------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
515.123.8080 07-6月 -02 AC_MGR
12008 101 110
SQL> select * from employees where employee_id=&id;
输入 id 的值: 206
原值 1: select * from employees where employee_id=&id
新值 1: select * from employees where employee_id=206
EMPLOYEE_ID FIRST_NAME
----------- ----------------------------------------
LAST_NAME
--------------------------------------------------
--------------------------------------------------
PHONE_NUMBER HIRE_DATE JOB_ID
---------------------------------------- -------------- --------------------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
206 William
Gietz
WGIETZ
EMPLOYEE_ID FIRST_NAME
----------- ----------------------------------------
LAST_NAME
--------------------------------------------------
--------------------------------------------------
PHONE_NUMBER HIRE_DATE JOB_ID
---------------------------------------- -------------- --------------------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
515.123.8181 07-6月 -02 AC_ACCOUNT
8300 205 110
SQL> select * from employees where employee_id=&&id;
输入 id 的值: 207
原值 1: select * from employees where employee_id=&&id
新值 1: select * from employees where employee_id=207
未选定行
SQL> select * from employees where employee_id=&&id;
原值 1: select * from employees where employee_id=&&id
新值 1: select * from employees where employee_id=207
未选定行
SQL> select * from employees where employee_id=&&id;
原值 1: select * from employees where employee_id=&&id
新值 1: select * from employees where employee_id=207
未选定行
SQL>