I have some hundred lines of code to create tables but schema name is hardcoded like SCHEMA_NAME1.TABLE_NAME in all DDL statements. How can I have this as a variable and use in all the places so that we can easily change in a single place for multiple locations of SCHEMA_NAME requirement.Please give your thoughts.
create table SCHEMA_NAME1.TABLE_NAME1(....);
create table SCHEMA_NAME1.TABLE_NAME2(....);
create table SCHEMA_NAME1.TABLE_NAME3(....);
I want something like this
var SCHEMA_NAME_VALUE ;
create table SCHEMA_NAME_VALUE.TABLE_NAME1(....);
create table SCHEMA_NAME_VALUE.TABLE_NAME2(....);
create table SCHEMA_NAME_VALUE.TABLE_NAME3(....);
create table &SCHEMA_NAME.TABLE_NAME1(....);and execute the script with schema parameter. If the code creates only tables, view or grants you can turn everything into singleCREATE SCHEMA AUTHORIZATIONcommand.&for each instance of the schema name would require the user to enter the schema name once for each instance of the substitution variable. Using either a double ampersand&&for the first occurrence, or anACCEPTcommand at the beginning of the script would allow for entering the value only once. TheACCEPTcommand is the more advisable method since it ensures you can set the value each time you run the script. You should also include anUNDEFINEat the end.&) variables, don't forget to double up the trailing period since a period is used as an optional termination character for the variable names. The period termination character is required when the variable is name is not followed by white space as is the case above, so you need to double it in order to not lose the period separating the schema name from the object name.