Like other relational databases,OracleCan also perform some implicit data conversion, which writesSQLStatement hasVeryYou can 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.
OracleIt can be implicitly converted between variable classes, for example, from String Conversion to numeric value.,Let's look at the example below.
SQL> select ename, Sal from EMP where sal = '000000 ′;
Ename Sal
-----------
The smith 1100
Adams 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. ResultOracleThe correct result is returned. This descriptionOracleImplicit direct conversion from string to numeric value.
Then compare the following example.
SQL> select last_day ('26-4Month-08') from dual;
Last_day ('
----
30-4Month-08
Here ourLast_dayThe function originally needs to provide a date type parameter, and we intentionally provide a string type parameter. HoweverOracleThe correct result is returned for us.OracleImplicit conversion from string to date is performed internally.
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 useSelect sysdate from dualThisSQLReturns the date format of your machine. GenerallyNls_langParameter Values
Both examples illustrateOracleSome implicit function conversions can be performed internally. Below isOracleIn general.
Slave |
To |
Varchar2 or char |
Number |
Varchar2 or char |
Date |
Number |
Varchar2 |
Date |
Varchar2 |
Note thatVarchar2,CharToDateIn the implicit conversion process, you must ensure that the format is the default time format of the local machine.
Except for implicit conversion,OracleIt also provides more flexible data type display conversion, which is more flexible.