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;