2

While converting an Oracle code block I found this:

IF :NEW.username != USER THEN

Now, my question - what exactly is USER in Oracle? In SQL Server I have:

SELECT name FROM sys.server_principals 

Is the 'name' here same as Oracle USER?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user3844877
  • 493
  • 4
  • 9
  • 18

1 Answers1

0

In SQL Server, the NAME in sys.database_principals is the USER. There was a similar question in dbastackexchange here https://dba.stackexchange.com/questions/22803/listing-the-existing-sql-server-logins-and-users

In Oracle, USER is an account through which you can log in to the database, and to establish the means by which Oracle Database permits access by the user.

For example, I connected to the sample schema "SCOTT", I connect like :

conn scott/tiger@database

So, here the user is "SCOTT". Let's see :

SQL> show user;
USER is "SCOTT"
Community
  • 1
  • 1
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
  • Thanks for this . So , in that case I think Oracle `USER'` is equivalent to SQL SERVER `SUSER_SNAME()` . Please comment if any of you think I am not correct . – user3844877 Oct 01 '14 at 12:32
  • No. It returns the login name, while a user and login name are not similar in SQL Server. One "Login" can be associated with many users (one per database). Have a look at similar question http://stackoverflow.com/questions/1134319/difference-between-a-user-and-a-login-in-sql-server – Lalit Kumar B Oct 01 '14 at 12:41