How can I make sure the end user has only one session in the database?
This can be a requirement of an application, well, we have not found a good reason for limiting people in this way. However, people want to do it and when they do, they usually do it the hard way. For example, they will have a batch job run by the operating system that will look at the V$SESSION table and arbitrarily kill sessions of users who have more then 1 session. Alternatively, they will create their own tables and have the application insert a row when a user logs in, and remove the row when they log out. This implementation invariably leads to lots of calls to the help desk because when the application 'crashes', the row never gets removed. There are lots of other 'creative' ways to do this, but none is as easy as:
SQL> create profile one_session limit sessions_per_user 1;
SQL> alter user scott profile one_session;
SQL> alter system set resource_limit=true;
That's it now any user with the ONE_SESSION profile can log on only once.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/936/viewspace-60614/，如需转载，请注明出处，否则将追究法律责任。