Oracle 10g中的用户何时启用角色?
我使用C#4中的ADO.NET为组件设置测试上下文 我以sysdba的身份执行以下SQL:Oracle 10g中的用户何时启用角色?,oracle,ado.net,oracle10g,Oracle,Ado.net,Oracle10g,我使用C#4中的ADO.NET为组件设置测试上下文 我以sysdba的身份执行以下SQL: new[] { "create user \"{0}\" identified externally default tablespace USER_DATA temporary tablespace TEMP profile DEFAULT" .FormatWith( Config.QualifiedUserName ), "create role {0}" .Forma
new[]
{
"create user \"{0}\" identified externally default tablespace USER_DATA temporary tablespace TEMP profile DEFAULT"
.FormatWith( Config.QualifiedUserName ),
"create role {0}"
.FormatWith( Config.RoleName ),
"grant {0} to \"{1}\""
.FormatWith( Config.RoleName, Config.QualifiedUserName ),
"insert into doc.application( id, name ) values( {0}, '{1}' )"
.FormatWith( Config.AppId, Config.AppName ),
"insert into doc.appl_role( application, role, description ) values( {0}, '{1}', '{2}' )"
.FormatWith( Config.AppId, Config.RoleName, Config.RoleDescription ),
"create table {0}.{1} ( ID number primary key, VERSION number, NAME varchar(100) )"
.FormatWith( Config.TestSchema, Config.TestTable ),
"insert into {0}.{1} (ID, VERSION, NAME) values ('{2}', '{3}', '{4}')"
.FormatWith( Config.TestSchema, Config.TestTable, Config.TestRowId, 1, Config.TestRowName ),
"grant select, insert, update, delete on {0}.{1} to {2}"
.FormatWith( Config.TestSchema, Config.TestTable, Config.RoleName ),
"grant create session to \"{0}\""
.FormatWith( Config.QualifiedUserName )
}
Config类如下所示:
public struct Config
{
public const Int32 TestRowId = 1;
public const Int32 AppId = 99999;
public const String AppName = "OraceUtils";
public const String RoleName = "ORACLE_UTILS_BASE";
public static readonly String RoleDescription = "For testing {0}".FormatWith( AppName );
public static readonly String QualifiedUserName = @"{0}\{1}".FormatWith( Domain, UserName );
public const String DataSource = "TESTDB";
public const String Domain = "BI";
public const String UserName = "ORACLE_TEST_USER";
public const String UserPassword = [for my eyes only];
public const String TestSchema = "CI";
public const String TestTable = "ROLE_PROVIDER_TEST_TABLE";
public const String TestRowName = "Arne And";
}
据我所知,仅仅授予用户一个角色并不能启用它。但是,在执行上述SQL之后,用户BI\ORACLE\u TEST\u用户可以很好地使用表角色\u PROVIDER\u TEST\u表。ORACLE_UTILS_BASE角色也显示在会话_角色中
如果我随后发出“设置角色”,上述用户将无法访问该表
我认为这是另一种方式,即用户只有在发出“设置角色ORACLE_UTILS_BASE[任何其他角色]”后才能访问数据库。当用户连接到数据库时,其所有默认角色都将启用。您可以使用Syntax更改默认角色:
ALTER USER <user> DEFAULT ROLE <role>
ALTER用户默认角色
可以是角色名称,也可以是关键字ALL
或NONE
当您将角色授予用户时,该角色将成为默认角色(即用户连接时不必使用SET role
激活该角色)