Like other relational databases, oracle can also perform some implicit data conversion, which is very useful for writing SQL statements. We do not need to manually convert many types of characters. Although we have introduced some methods for force conversion using functions such as to_char and to_date, implicit conversion is still good. Orac
Like other relational databases, oracle can also perform some implicit data conversion, which is very useful for writing SQL statements. We do not need to manually convert many types of characters. Although we have introduced some methods for force conversion using functions such as to_char and to_date, implicit conversion is still good. Orac
Like other relational databases, oracle can also perform some implicit data conversion, which is very useful for writing SQL statements. We do not need to manually convert many types of characters. Although we have introduced some methods for force conversion using functions such as to_char and to_date, implicit conversion is still good.
Oracle can implicitly convert variable classes, for example, from String Conversion to numeric values. See the following example.
SQL> select ename,sal from emp where sal = ‘1100′; ENAME SAL——————– ———-SMITH 1100ADAMS 1100
The employee's salary was chosen here. We knew that the employee's salary was numeric, But we deliberately wrote it as a string. The oracle still returns the correct result. This indicates that oracle performs implicit conversion from string to value.
Then compare the following example.
SQL> Select last_day ('26-April-08 ') from dual; LAST_DAY (' ---- 30-4 month-08
Here, our last_day function is supposed to provide a date type parameter, and we intentionally provide a string type parameter. However, oracle still returns the correct result, which indicates that oracle has performed implicit conversion from string to date. It should be noted that, if this example is not successfully executed on your machine, it is very likely that your default date format is different from this, if you do not know your date format, you can use
select sysdate from dual
The result returned by this SQL statement is used to view the date format of your machine. Generally, this is related to the value of the NLS_lang parameter.
Both examples show that oracle can indeed perform some Implicit Function Conversion. The following is a general case of implicit conversions in oracle.
|
Slave |
To |
|
Varchar2 or Char |
Number |
|
Varchar2 or Char |
Date |
|
Number |
Varchar2 |
|
Date |
Varchar2 |
Note that during implicit conversion from Varchar2 and char to date, the format must be the default time format of the local machine.
In addition to implicit conversions, oracle also provides more flexible display conversions for data types. This conversion method is more flexible.