日期:2014-05-16 浏览次数:20508 次
SELECT TRUNC (SYSDATE, 'MONTH') "First day of current month" FROM DUAL;
SELECT TRUNC (LAST_DAY (SYSDATE)) "Last day of current month" FROM DUAL;
SELECT TRUNC (SYSDATE, 'YEAR') "Year First Day" FROM DUAL;
SELECT ADD_MONTHS (TRUNC (SYSDATE, 'YEAR'), 12) - 1 "Year Last Day" FROM DUAL
SELECT CAST (TO_CHAR (LAST_DAY (SYSDATE), 'dd') AS INT) number_of_days FROM DUAL;
SELECT SYSDATE, LAST_DAY (SYSDATE) "Last", LAST_DAY (SYSDATE) - SYSDATE "Days left" FROM DUAL;获取两个日期之间的天数
SELECT ROUND ( (MONTHS_BETWEEN ('01-Feb-2014', '01-Mar-2012') * 30), 0) num_of_days FROM DUAL; OR SELECT TRUNC(sysdate) - TRUNC(e.hire_date) FROM employees;
SELECT ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), i) start_date, TRUNC (LAST_DAY (ADD_MONTHS (SYSDATE, i))) end_date FROM XMLTABLE ( 'for $i in 0 to xs:int(D) return $i' PASSING XMLELEMENT ( d, FLOOR ( MONTHS_BETWEEN ( ADD_MONTHS (TRUNC (SYSDATE, 'YEAR') - 1, 12), SYSDATE))) COLUMNS i INTEGER PATH '.');
SELECT (SYSDATE - TRUNC (SYSDATE)) * 24 * 60 * 60 num_of_sec_since_morning FROM DUAL;
SELECT (TRUNC (SYSDATE+1) - SYSDATE) * 24 * 60 * 60 num_of_sec_left FROM DUAL;
SELECT table_name FROM user_tables WHERE table_name = 'TABLE_NAME';
SELECT column_name AS FOUND FROM user_tab_cols WHERE table_name = 'TABLE_NAME' AND column_name = 'COLUMN_NAME';
SELECT DBMS_METADATA.get_ddl ('TABLE', 'TABLE_NAME', 'USER_NAME') FROM DUAL;
SELECT SYS_CONTEXT ('userenv', 'current_schema') FROM DUAL;
ALTER SESSION SET CURRENT_SCHEMA = new_schema;数据库管理查询