Tech and travel

Using COLUMN in SQL*Plus

2007-03-19

Here’s something I learned about SQL*Plus today. If you want to create a variable in a script, you can use the COLUMN command. In the following script, 2 variables called HOST_NAME and DATABASE_NAME are created. Their values are filled in when the SELECT statement executes.

col host_name new_value HOST_NAME
col instance_name new_value DATABASE_NAME

SELECT host_name, instance_name  FROM v$instance;

UPDATE table SET value = '&&HOST_NAME'

Copyright (c) 2024 Michel Hollands