Oracle implicit conversion

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.