Common oracle function operations

Source: Internet
Author: User

1: Give the time, for example, "2011-7-23". query the day of the week;

Select to_char (to_date ('1970-7-23 ', 'yyyy-mm-dd'), 'day', 'nls _ DATE_LANGUAGE = American') from dual;

Result: Saturday

Select to_char (to_date ('1970-7-23 ', 'yyyy-mm-dd'), 'day') from dual;

Result: Saturday

2: Query System time;

Select sysdate from dual;

3: round () Rounding, trunc (x, y) truncates the decimal place floor (y)

4: Print Output cyclically:

SQL> set serverout on SQL> begin    2    for i in 1..10 loop    3      dbms_output.put_line(round(dbms_random.value*100));    4    end loop;    5  end;    6  / 

You must enable the server output. Otherwise, no result is displayed.

5: Number of rows before rownum implicit cursor

Select id from xx table where rownum <xx; subquery is required if order by exists.

Select A. id from (select id from B order by name) a where orwnum <xx;

6: query the IP address of a local machine.

Select UTL_INADDR.get_host_address () from dual;

  select UTL_INADDR.get_host_address('www.qq.com') from dual;

 



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.