Pole share posted on 2015-11-05-16:54 1/440 45 Very useful Oracle query statements ____oracle

Source: Internet
Author: User
Pole share posted on 2015-11-05-16:54 1/440 45 Very useful Oracle query statementsJust look at the floor of the landlord. Here we introduce a very useful Oracle query statement, mainly covers the date operation, get the server information, get the execution status, calculate the database size and so on inquiries. 40+ These are the skills that all Oracle developers must have, so collect them quickly.


Date/Time related queries


1. Get the first day of the current month
Run this command to quickly return to the first day of the current month. You can replace "sysdate" with any date value to specify the date of the query.

Copy Code
1 2 3 Select TRUNC (sysdate, ' MONTH ') "The" of the "a", "the", "from DUAL;"

2. Get the last day of the current month
This query is similar to the above statement and takes care of the leap year, so when you have number 29th in February, you will return 29/2. You can replace "sysdate" with any date value to specify the date of the query.

Copy Code
1 2 3 Select TRUNC (Last_day (sysdate)) "Last day of the current month" from DUAL;

3. Get the first day of the current year
The first day of the year is January 1, and this query statement can be used in a stored procedure that requires some calculation of the first day of the current year. You can replace "sysdate" with any date value to specify the date of the query.

Copy Code
1 Select TRUNC (Sysdate, ' year ') "year a" from DUAL;

4. Get the last day of the current year
Similar to the query statement above. You can replace "sysdate" with any date value to specify the date of the query.

Copy Code
1 SELECT add_months (TRUNC (Sysdate, ' year ')-1 "Year's last Day" from DUAL

5. Get the number of days in the current month
This statement is useful to calculate the number of days in the current month. You can replace "sysdate" with any date value to specify the date of the query.


Copy Code
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.