To accomplish what you are trying to use in a toad, you do not need to declare a variable at all. Just include the colon-preceded variable, and Toad will offer you the value of the variable when you run the query. For instance:
select * from all_tables where owner = :this_is_a_variable;
If this does not work initially, right-click anywhere in the editor and make sure the "Request Substitution Variables" checkbox is checked.
If you really want to do this in the same way that SQL Server handles variables (or you want to be able to do the same in SQL * Plus), you can write it like this:
var this_is_a_variable varchar2(30); exec :this_is_a_variable := 'YOUR_SCHEMA_NAME'; print this_is_a_variable; select * from all_tables where owner = :this_is_a_variable;
However, to make this work in Toad, you need to run it through the "Execute as script", and not in the typical "Execute statement" command.
Allan source share