It depends on tool you use. In SQL*Plus, you'd precede it with &
SELECT * FROM table WHERE id = &tmp;
In some other tools (SQL Developer, TOAD), that would be :
SELECT * FROM table WHERE id = :tmp;
If you're using the same variable more than once in the same query, precede it with two ampersands:
SQL> set linesize 200
SQL> set ver off
SQL> select *
2 from (select *
3 from emp
4 where deptno = &&deptno
5 )
6 where deptno = &&deptno;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
7782 CLARK MANAGER 7839 09.06.81 2450 10
7839 KING PRESIDENT 17.11.81 5000 10
7934 MILLER CLERK 7782 23.01.82 1300 10
SQL>
However, if you run the same query once again, you won't be prompted for the variable (as it is "remembered"):
SQL> /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
7782 CLARK MANAGER 7839 09.06.81 2450 10
7839 KING PRESIDENT 17.11.81 5000 10
7934 MILLER CLERK 7782 23.01.82 1300 10
SQL>
You'll need to undefine it first:
SQL> undefine deptno
SQL> /
Enter value for deptno: 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17.12.80 800 20
7566 JONES MANAGER 7839 02.04.81 2975 20
7788 SCOTT ANALYST 7566 09.12.82 3000 20
7876 ADAMS CLERK 7788 12.01.83 1100 20
7902 FORD ANALYST 7566 03.12.81 3000 20
SQL>