How to present Oracle's relative functions in DB2 (II.)

Source: Internet
Author: User
Tags date continue current time db2 empty functions reference relative
Oracle
How to present Oracle's relative functions in DB2 (II.)
Author:ccbzzp
In reality, you may often encounter some of the functions of Oracle in DB2,
Here I simply conclude that there may be many ways in which a function can be found, not all of which are listed here,
Welcome to all of you to continue, in order to share with you, to explore together, common approach! (the following are mainly Oracle
8i,9i and DB2 7.X for example).
1. How to view the version of Oracle and DB2 in a digital library
Oracle can actually do this:
Sql> Connect system/manager124@test;
Already connected.
Sql> select * from V$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0-production
Pl/sql Release 9.2.0.1.0-production
CORE 9.2.0.1.0 Production
TNS for 32-bit windows:version 9.2.0.1.0-production
Nlsrtl Version 9.2.0.1.0-production

DB2 can actually do this:
To perform db2level in a command window
D:qllib\bin>db2level
DB210851 Instance "DB2" uses DB2 code release "SQL07020" and level identifier
"03010105" and Informational tokens "DB2 v7.1.0.40", "n010415" and "WR21254".
2. How to quickly empty a large table of Oracle and DB2 write method
Oracle can actually do this:
Sql>truncate table table_name;
DB2 can actually do this:
ALTER TABLE table_name active not logged initially with empty table;
3. How to view the use of the table space Oracle and DB2 write method
Oracle can actually do this:
SELECT Tablespace_name, Max_m, Count_blocks free_blk_cnt, Sum_free_m,to_char (100*sum_free_m/sum_m, ' 99.99 ') | | '% ' as

Pct_free
From (SELECT tablespace_name,sum (bytes)/1024/1024 as sum_m from Dba_data_files GROUP by Tablespace_name),
(SELECT tablespace_name as Fs_ts_name, max (bytes)/1024/1024 as Max_m, COUNT (blocks) as Count_blocks,

SUM (bytes/1024/1024) as sum_free_m from Dba_free_space GROUP by Tablespace_name)
WHERE Tablespace_name = Fs_ts_name
DB2 can actually do this:
List tablespace containers for your table space number show detail;
4. How to extract the common Oracle and DB2 of the various parts of the date from a point of time
Oracle can actually do this:
1&gt: The writing method of the year in which the time is taken
SELECT to_char (sysdate, ' YYYY ') from DUAL;
2&gt: The writing method of the month of the time
SELECT to_char (sysdate, ' MM ') from DUAL;
3&gt: The day of the time to write
SELECT to_char (sysdate, ' DD ') from DUAL;
4&gt: The writing method of time
SELECT to_char (sysdate, ' HH24 ') from DUAL;
5&gt: The writing method of the time point
SELECT to_char (sysdate, ' MI ') from DUAL;
6&gt: The writing of the Seconds of time
SELECT to_char (sysdate, ' SS ') from DUAL;
7&gt: (a) The millisecond of the time point is written (9I above)
Select SUBSTR (systimestamp,20,6) from dual;
8&gt: The written method of the date of the time
SELECT TRUNC (sysdate) from DUAL;
9&gt: The time of Time to write
SELECT to_char (sysdate, ' HH24:MI:SS ') from DUAL;
10> date, the time form becomes the character form
SELECT To_char (sysdate) from DUAL;
11> Convert a string to a date or time form:
SELECT to_date (' 2003/08/01 ') from DUAL;
12> Returns the number of days of the week in which the parameters are written:
SELECT to_char (sysdate, ' D ') from DUAL;
13&GT: Returns the number of days of the year in which the reference is written.
SELECT to_char (sysdate, ' DDD ') from DUAL;
14&gt. Returns the number of seconds between the time values specified in the midnight and the parameters:
SELECT to_char (sysdate, ' sssss ') from DUAL;
15&gt: Returns the writing of the first weeks of the year in the parameters
SELECT to_char (sysdate, ' WW ') from DUAL;

DB2 can actually do this:
1&gt: The writing method of the year in which the time is taken
SELECT year [current timestamp] from SYSIBM. SYSDUMMY1;
2&gt: The writing method of the month of the time
SELECT MONTH (current timestamp) from SYSIBM. SYSDUMMY1;
3&gt: The day of the time to write
SELECT Day, current timestamp, from SYSIBM. SYSDUMMY1;
4&gt: The writing method of time
SELECT HOUR (current timestamp) from SYSIBM. SYSDUMMY1;
5&gt: The writing method of the time point
SELECT MINUTE (current timestamp) from SYSIBM. SYSDUMMY1;
6&gt: The writing of the Seconds of time
SELECT SECOND (current timestamp) from SYSIBM. SYSDUMMY1;
7&gt: A millisecond's notation for taking time
SELECT microsecond (current timestamp) from SYSIBM. SYSDUMMY1;
8&gt: The written method of the date of the time
SELECT DATE (timestamp) from SYSIBM. SYSDUMMY1;
9&gt: The time of Time to write
SELECT time (timestamp) from SYSIBM. SYSDUMMY1;
10> date, the time form becomes the character form:
SELECT char (current date) from SYSIBM. SYSDUMMY1;
SELECT char (current time) from SYSIBM. SYSDUMMY1;
SELECT char (current date+12 hours) from SYSIBM. SYSDUMMY1;
11> Convert a string to a date or time form:
SELECT TIMESTAMP (' 2002-10-20-12.00.00.000000 ') from SYSIBM. SYSDUMMY1;
SELECT TIMESTAMP (' 2002-10-20 12:00:00 ') from SYSIBM. SYSDUMMY1;
SELECT DATE (' 2002-10-20 ') from SYSIBM. SYSDUMMY1;
SELECT DATE (' 10/20/2002 ') from SYSIBM. SYSDUMMY1;
SELECT time (' 12:00:00 ') from SYSIBM. SYSDUMMY1;
SELECT time (' 12.00.00 ') from SYSIBM. SYSDUMMY1;
12> Returns the number of days of the week in which the parameters are written:
SELECT Dayname (current timestamp) from SYSIBM. SYSDUMMY1;
SELECT DayOfWeek (current timestamp) from SYSIBM. SYSDUMMY1;
SELECT Dayofweek_iso (current timestamp) from SYSIBM. SYSDUMMY1;
13&GT: Returns the number of days of the year in which the reference is written.
SELECT DayOfYear (current timestamp) from SYSIBM. SYSDUMMY1;
14&gt. Returns the number of seconds between the time values specified in the midnight and the parameters:
SELECT Midnight_seconds (current timestamp) FORM SYSIBM. SYSDUMMY1;
15&gt: Returns the writing of the first weeks of the year in the parameters
SELECT WEEK (current timestamp) FORM SYSIBM. SYSDUMMY1;

To continue ...






Related Article

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.