• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Mysql > oracle的一些tips技巧_Oracle应用_脚本之家

oracle的一些tips技巧_Oracle应用_脚本之家

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-05

匿名通过本文主要向大家介绍了oracle,tips,技巧等相关知识,希望本文的分享对您有所帮助

oracle的一些tips技巧

最近群里好多人讨论oracle安全问题,今天找了些资料学习了下

获取Oracle当前会话的一些属性 (对于sql注射的环境判断很有用哦)

SYS_CONTEXT 函数返回是与上下文名称空间相关的属性值。这个函数可以用在SQL和PL/SQL语句中。
注意: SYS_CONTEXT 返回的是用户会话期间的属性,所以,你无法使用它在并行的查询或实时应用集群环境。

对于名称空间和变量, 你可以定义它(们)为常量字符串,也可以定义一个变量,来代替名称空间或属性的字符串。名称空间必须是已经在数据库中定义好的, 并且相关的参数和值已经被指定到DBMS_SESSION中。名称空间必须是一个合法的SQL标识符。变量名字可以是任意的字符串。它们不区分大小写, 但是长度不能超出30个字节。

函数返回的数据类型是VARCHAR2,回归值的缺省最大长度是256个字节。你也可以通过设置函数参数length来修改这个缺省长度值。值的合法的长度范围是1到4000字节。(如果你指定的值不在这个范围内, Oracle将使用缺省长度。)

Oracle9i 提供了一个内置的"USERENV"名称空间, 用来表示当前的会话信息。该名称空间预定义的参数如表1, 表的最后一列标识了返回值的长度。

语法:
SYS_CONTEXT(namespace, attribute[, length])

例子:
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_CONTEXT ('USERENV', 'AUTHENTICATION_DATA') AUTHENTICATION_DATA
FROM DUAL;

下面的语句返回登录用户的名字:

CONNECT OE/OE
select SYS_CONTEXT ('USERENV', 'SESSION_USER')
FROM DUAL;
SYS_CONTEXT ('USERENV', 'SESSION_USER')




网上找的
[code]AUTHENTICATION_DATA
Data being used to authenticate the login user. For X.503 certificate authenticated sessions, this field returns the context of the certificate in HEX2 format.
256


Note: You can change the return value of the AUTHENTICATION_DATA attribute using the length parameter of the syntax. Values of up to 4000 are accepted. This is the only attribute of USERENV for which Oracle implements such a change.


AUTHENTICATION_TYPE
How the user was authenticated:

DATABASE: username/password authentication

OS: operating system external user authentication

NETWORK: network protocol or ANO authentication

PROXY: OCI proxy connection authentication

30

BG_JOB_ID
Job ID of the current session if it was established by an Oracle background process. Null if the session was not established by a background process.
30

CLIENT_INFO
Returns up to 64 bytes of user session information that can be stored by an application using the DBMS_APPLICATION_INFO package.
64

CURRENT_SCHEMA
Name of the default schema being used in the current schema. This value can be changed during the session with an alter SESSION SET CURRENT_SCHEMA statement.
30

CURRENT_SCHEMAID
Identifier of the default schema being used in the current session.
30

CURRENT_USER
The name of the user whose privilege the current session is under.
30

CURRENT_USERID
User ID of the user whose privilege the current session is under
30

DB_DOMAIN
Domain of the database as specified in the DB_DOMAIN initialization parameter.
256

DB_NAME
Name of the database as specified in the DB_NAME initialization parameter
30

ENTRYID
The available auditing entry identifier. You cannot use this option in distributed SQL statements. To use this keyword in USERENV, the initialization parameter AUDIT_TRAIL must be set to true.
30

EXTERNAL_NAME
External name of the database user. For SSL authenticated sessions using v.503 certificates, this field returns the distinguished name (DN) stored in the user certificate.
256

FG_JOB_ID
Job ID of the current session if it was established by a client foreground process. Null if the session was not established by a foreground process.
30

HOST
Name of the host machine from which the client has connected.
54

INSTANCE
The instance identification number of the current instance.
30

IP_ADDRESS
IP address of the machine from which the client is connected.
30

ISDBA
TRUE if you currently have the DBA role enabled and FALSE if you do not.
30

LANG
The ISO abbreviation for the language name, a shorter form than the existing 'LANGUAGE' parameter.
62

LANGUAGE
The language and territory currently used by your session, along with the database character set, in this form:

language_territory.characterset
52

NETWORK_PROTOCOL
Network protocol being used for communication, as specified in the 'PROTOCOL=protocol' portion of the connect string.
256

NLS_CALENDAR
The current calendar of the current session.
62

NLS_CURRENCY
The currency of the current session.
62

NLS_DATE_FORMAT
The date format for the session.
62

NLS_DATE_LANGUAGE
The language used for expressing dates.
62

NLS_SORT
BINARY or the linguistic sort basis.
62

NLS_TERRITORY
The territory of the current session.
62

OS_USER
Operating system username of the client process that initiated the database session
30

PROXY_USER
Name of the database user who opened the current session on behalf of SESSION_USER.
30

PROXY_USERID
Identifier of the database user who opened the current session on behalf of SESSION_USER.
30

SESSION_USER
Database user name by which the current user is authenticated. This value remains the same throughout the duration of the session.
30

SESSION_USERID
Identifier of the database user name by which the current user is authenticated.
30

SESSIONID
The auditing session identifier. You cannot use this option in distributed SQL statements.
30

TERMINAL
The operating system identifier for the client of the current session. In distributed SQL statements, this option returns the identifier for your local session. In a distributed environment, this is supported only for remote select statements, not for remote insert, update, or delete operations. (The return length of this parameter may vary by operating system.)
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 浅析drop user与delete from mysql.user的区别
  • mysql prompt的用法详解
  • 如何使用索引提高查询速度
  • 深入mysql创建自定义函数与存储过程的详解
  • JDBC数据库的使用操作总结
  • MySQL查询优化:LIMIT 1避免全表扫描提高查询效率
  • MySQL与Oracle的语法区别详细对比
  • 有关mysql中ROW_COUNT()的小例子
  • MySQL 百万级分页优化(Mysql千万级快速分页)
  • 从创建数据库到存储过程与用户自定义函数的小感

相关文章

  • 2018-12-05sqlserver 中时间为空的处理小结
  • 2018-12-05Oracle一个用户如何访问其它用户的表应用指南
  • 2018-12-05sqlserver 快速生成汉字的首拼字母的函数(经典)
  • 2018-12-05详解mysql之数据备份与恢复
  • 2018-12-05MySQL大表中重复字段的高效率查询方法
  • 2018-12-05MySQL事件的使用详解
  • 2018-12-05mysql备份恢复mysqldump.exe几个常用用例
  • 2017-05-11Mysql 插入中文及中文查询 (修改+调试)
  • 2017-05-11centos下mysql主从同步快速设置步骤分享
  • 2018-12-05MySQL中文乱码如何解决?

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • mysql Myisamchk小工具使用手册第1/2页
    • VPS下修改MySQL root用户密码的方法
    • SQL SERVER 2005 最小安装经验
    • 详解MySQL5.7主从配置的实例代码
    • MySQL 数据类型 详解
    • windows下重启mysql的方法
    • 简单介绍mysql 的时间函数以及实例
    • mysql 按中文字段排序
    • MySQL服务器连接过程浅析
    • 双机HA函数定义与用法汇总

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有