In order to explain this, I am going to create tables which will produce todays date which will be substituted using a variable. In order to this follow the below steps.
1. Execute the following statement, in order to assign the value for the today vairable:
SQL> column today new_value today
2. Execute the following statement, in order to obtain today's date, and have the value assigned to the column alias today:
SQL> select to_char(sysdate,'DD/MM/RR') today from dual;
TODAY
--------
26/09/10
3. Now if u check the variable value for the variable TODAY, it would provide you todays value which basically executes the sysdate function and obtains today's value.
SQL> define today
DEFINE TODAY = "05/02/10" (CHAR)
DEFINE TODAY = "05/02/10" (CHAR)
4. Then execute the create table command and obtain the table, which will possess today's date by having the variable TODAY that was created. REMEMBER, in order to execute and obtain the desired output successfully you will have to have the database object name within double quotes (" "). I have demonstrated the error message which will popup if the double quotes are not used, and the correct way of having the syntax..
SQL> create table table_&today
2 (id number);
old 1: create table table_&today
new 1: create table table_05/02/10
create table table_05/02/10
*
ERROR at line 1:
ORA-00922: missing or invalid option
******************************************************
SQL> l
1 create table table_&today
2* (id number)
SQL> 1
1* create table table_&today
SQL> c/table_&today/"table_&today"
1* create table "table_&today"
SQL> l
1 create table "table_&today"
2* (id number)
SQL> /
old 1: create table "table_&today"
new 1: create table "table_05/02/10"
Table created.
SQL>
Hope this helps!!!
0 comments:
Post a Comment