OracleÖÐUSERENVºÍSYS_CONTEXT×ܽá[ת]
OracleÖÐUSERENVºÍSYS_CONTEXTÓÃÀ´·µ»Øµ±Ç°sessionµÄÐÅÏ¢£¬ÆäÖУ¬userenvÊÇΪÁ˱£³ÖÏòϼæÈݵÄÒÅÁôº¯Êý£¬ÍƼöʹÓÃsys_contextº¯Êýµ÷ÓÃuserenvÃüÃû¿Õ¼äÀ´»ñÈ¡Ïà¹ØÐÅÏ¢¡£
1¡¢ USERENV(OPTION)
¡¡¡¡·µ»Øµ±Ç°µÄ»á»°ÐÅÏ¢.
¡¡¡¡OPTION='ISDBA'Èôµ±Ç°ÊÇDBA½ÇÉ«,ÔòΪTRUE,·ñÔòFALSE.
¡¡¡¡OPTION='LANGUAGE'·µ»ØÊý¾Ý¿âµÄ×Ö·û¼¯.
¡¡¡¡OPTION='SESSIONID'Ϊµ±Ç°»á»°±êʶ·û.
¡¡¡¡OPTION='ENTRYID'·µ»Ø¿ÉÉó¼ÆµÄ»á»°±êʶ·û.
¡¡¡¡OPTION='LANG'·µ»Ø»á»°ÓïÑÔÃû³ÆµÄISO¼ò¼Ç.
¡¡¡¡OPTION='INSTANCE'·µ»Øµ±Ç°µÄʵÀý.
OPTION='terminal'·µ»Øµ±Ç°¼ÆËã»úÃû
¡¡¡¡SELECT USERENV('LANGUAGE') from DUAL;
2¡¢sys_context
select
SYS_CONTEXT('USERENV','TERMINAL') terminal,
SYS_CONTEXT('USERENV','LANGUAGE') language,
SYS_CONTEXT('USERENV','SESSIONID') sessionid,
SYS_CONTEXT('USERENV','INSTANCE') instance,
SYS_CONTEXT('USERENV','ENTRYID') entryid,
SYS_CONTEXT('USERENV','ISDBA') isdba,
SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,
SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,
SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
SYS_CONTEXT('USERENV','CURRENT_USER') current_user,
SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,
SYS_CONTEXT('USERENV','SESSION_USER') session_user,
SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,
SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,
SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,
SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,
SYS_CONTEXT('USERENV','DB_NAME') db_name,
SYS_CONTEXT('USERENV','HOST') host,
SYS_CONTEXT('USERENV','OS_USER') os_user,
SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,
SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,
SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol,
SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,
SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,
SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE') authentication_type,
SYS_CONTEX
Ïà¹ØÎĵµ£º
ÓÐÁ½ÖÖº¬ÒåµÄ±í´óС¡£Ò»ÖÖÊÇ·ÖÅä¸øÒ»¸ö±íµÄÎïÀí¿Õ¼äÊýÁ¿£¬¶ø²»¹Ü¿Õ¼äÊÇ·ñ±»Ê¹Ó᣿ÉÒÔÕâÑù²éѯ»ñµÃ×Ö½ÚÊý£º
select segment_name, bytes
from user_segments
where segment_type = 'TABLE';
»òÕß
Select Segment_Name,Sum(bytes)/1024/1024 from User_Extents Group By Segment_Name
ÁíÒ»ÖÖ±íÊ ......
--»ñÈ¡Á½Ê±¼äµÄÏà²îºÀÃëÊý
select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('2008-04-30 23:59:59' , 'yyyy-mm-dd hh24-mi-ss')) * 24 * 60 * 60 * 1000) Ïà²îºÀÃëÊý from DUAL;
/*
Ïà²îºÀÃëÊý
----------
86401000
1 row selected
*/
--»ñÈ¡Á½Ê±¼äµÄÏà²îÃëÊý
select ce ......
¾³£ÓÐͬÊÂ×ÉѯoracleÊý¾Ý¿â×Ö·û¼¯Ïà¹ØµÄÎÊÌ⣬ÈçÔÚ²»Í¬Êý¾Ý¿â×öÊý¾ÝǨÒÆ¡¢Í¬ÆäËüϵͳ½»»»Êý¾ÝµÈ£¬³£³£ÒòΪ×Ö·û¼¯²»Í¬¶øµ¼ÖÂǨÒÆʧ°Ü»òÊý¾Ý¿âÄÚÊý¾Ý±ä³ÉÂÒÂë¡£ÏÖÔÚÎÒ½«oracle×Ö·û¼¯Ïà¹ØµÄһЩ֪ʶ×ö¸ö¼òµ¥×ܽᣬϣÍû¶Ô´ó¼Ò½ñºóµÄ¹¤×÷ÓÐËù°ïÖú¡£
¡¡¡¡Ò»¡¢Ê²Ã´ÊÇoracle×Ö·û¼¯
¡¡¡¡Oracle×Ö·û¼¯ÊÇÒ»¸ö×Ö½ÚÊý¾ÝµÄ½âÊÍ ......
Oracle ·ÖÎöº¯ÊýʹÓýéÉÜ
·ÖÎöº¯ÊýÊÇoracle816ÒýÈëµÄÒ»¸öȫеĸÅÄî,ΪÎÒÃÇ·ÖÎöÊý¾ÝÌṩÁËÒ»ÖÖ¼òµ¥¸ßЧµÄ´¦Àí·½Ê½.ÔÚ·ÖÎöº¯Êý³öÏÖÒÔÇ°,ÎÒÃDZØÐëʹÓÃ×ÔÁª²éѯ,×Ó²éѯ»òÕßÄÚÁªÊÓͼ,ÉõÖÁ¸´ÔӵĴ洢¹ý³ÌʵÏÖµÄÓï¾ä,ÏÖÔÚÖ»ÒªÒ»Ìõ¼òµ¥µÄsqlÓï¾ä¾Í¿ÉÒÔʵÏÖÁË,¶øÇÒÔÚÖ´ÐÐЧÂÊ·½ÃæÒ²ÓÐÏ൱´óµÄÌá¸ß.ÏÂÃæÎÒ½«Õë¶Ô·ÖÎöº¯ ......
1. ´´½¨ÊÓͼ£º
CREATE OR REPLACE VIEW SM_V_UNIT_AUTH AS
SELECT T2.UNIT_ID,
T2.SUPER_UNIT_ID,
T1.AUTH_ID,
T1.AUTH_NAME,
T1.A ......