DEFINE
DEFINE is a SQL*Plus command used in Oracle database systems to set a variable to a specific value. In SQL scripts, these variables can later be referenced for performing actions on a database.
Example
DEFINE customer_id = 10;SELECT * FROM customers WHERE id = &customer_id;UNDEFINE customer_id;Output
| id | first_name | last_name | |
|---|---|---|---|
| 10 | John | Doe | john.doe@example.com |
Explanation
In the example, the DEFINE command is used to create a substitution variable named customer_id with a value of 10. This substitution variable is then referenced in the SELECT statement using an ampersand & just before the variable name to retrieve the customer record with id 10. The UNDEFINE statement at the end removes the substitution variable.