Tuesday, December 13, 2016

Oracle Passwords - how to unlock and change

Oracle passwords - changing, expiring and locking users

Oracle Tips by Steve Karam, OCM

See these important notes on how to un-lock a database and make_a password_not_expire.

Change Oracle passwords, expire, and lock unnecessary usersThere are many users on a full installation of Oracle, most of which you probably won't need. To lock an Oracle user account, you can use the following command:
alter user username account lock;
To unlock the user, simply replace 'lock' with 'unlock.'
Oracle comes with a few default accounts that should never be locked or dropped. These include: SYS, SYSTEM, SYSMAN (Oracle 10g), OUTLN. However, you do want always to change the password for these users. The default password for SYS is change_on_install. It is important that you follow these directions. To change the password for a user:
alter user username identified by new_password;
For non-critical users, you can always lock and expire the account. We can change the password for, lock, and expire the account CTXSYS all at once:
alter user ctxsys identified by 0bscur3 account lock password expire;
This will ensure that CTXSYS password has been changed from the self evident default of CTXSYS; on a successful login the password will have to be changed (because it is expired); and because it is locked, he account can't be logged into under any circumstances.
To aid you in this task, here is a list of users that come with a full database installation that are safe to expire and lock if you are not using their functionality:
  1. AURORA$ORB$UNAUTHENTICATED - Jserver user
  2. BI - demo user
  3. CTXSYS - Oracle Text/interMedia administrator
  4. DBSNMP - Oracle Intelligent Agent
  5. DSSYS - Dynamic Services and Syndication Server
  6. HR - demo user
  7. MDSYS - Spatial administrator
  8. ORDSYS/ORDPLUGIN - Object Relational Data user
  9. OE - demo user
  10. PERFSTAT - Statspack administrative user
  11. SCOTT - demo user
  12. SH - demo user
  13. TRACESVR - Oracle trace server
  14. WKSYS - Ultrasearch administrator
The best rule of thumb is to install only the features you need when you install Oracle. If you are not going to use Spatial, interMedia, or UltraSearch, don't install them. Then you will not have to worry about those three users.
Once an account has been expired, it can only be revived by assigning it a new password.  You can save the old password.

ALTER USER scott IDENTIFIED BY tiger;

You can then re-add the original password, provided that password_reuse_max is greater than zero.

Also see our notes on:

Friday, December 9, 2016

SQLDeveloper - How to change SAVE AS default path for files and Export

2
Is there a way to configure the directory SQL Developer uses to save SQL scripts?
When I do ... File, New, SQL File ... the directory is always set to the \AppData\Roaming\ for my user.
I'd like to set the default to a directory in my dev source code tree.
shareimprove this question
  
If it is hardcoded, you should think about just dropping a symlink to your desired directory in Appdata\roaming. – surfasb Mar 6 '12 at 14:57
  
Checked the registry and can't find any setting – SteveC Mar 8 '12 at 16:15

3 Answers


When you go to save your sql file you can change where the save defaults to. Change it in Tools>Preferences>Database>Worksheet Parameters. You can browse to a new location under "Select default path to look for scripts"
Can also change the Export Data so that it defaults to somewhere else. Go to Tools>Preferences>Database>Export and Browse to the location you want to export to for "Directory"
This used to annoy me bad before I changed it. Now all my saves and exports default to a folder I actually use.
shareimprove this answer


Found it ...
In the Choose Directory dialog, the left hand side has a number of commonly used short cuts, e.g. Desktop, Documents, but you can also have your own directories in there
shareimprove this answer

There is a post about this in OTN, and AlexAnd's solution opens the specified folder when I do File => Open.
The post is @
AlexAnd is saying that locate "\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf" and simply add "AddVMOption -Dide.user.dir=" (where " is the full folder path that you like to use) to that file.
The disadvantage of this solution is that it will also move your settings folders to the specified folder (for me it was about 34MB), I use drop box to keep my queries so that is a wasted space.

Wednesday, December 7, 2016

How to find a session in Oracle DB and kill it.

select inst_id,sid,serial# from gv$session where username='HYP_CCC'; alter system kill session '70,5,@1' ; ---------- Other code that works: SELECT 'alter system kill session'||chr(39)||sid||','||serial#||','||chr(64)||inst_id||chr(39)||';' FROM gv$session where username = 'HYP_CCC'; SELECT 'alter system kill session'||chr(39)||sid||','||serial#||','||chr(64)||inst_id||chr(39)||';' FROM gv$session where type = 'USER'; SELECT 'alter system kill session'||chr(39)||sid||','||serial#||','||chr(64)||inst_id||chr(39)||';' FROM gv$session WHERE username IS NOT NULL OR username <> 'SYS'; alter system kill session'5,13,@1'; alter system kill session'6,107,@1'; alter system kill session'8,11,@1'; alter system kill session'9,5521,@1'; alter system kill session'14,2221,@1'; alter system kill session'15,2233,@1'; alter system kill session'16,692,@1'; alter system kill session'68,3,@1'; alter system kill session'70,5,@1'; alter system kill session'73,2270,@1'; alter system kill session'74,3350,@1'; alter system kill session'75,3255,@1'; alter system kill session'130,7,@1'; alter system kill session'133,2867,@1'; alter system kill session'134,1234,@1'; alter system kill session'145,1937,@1'; alter system kill session'146,902,@1'; alter system kill session'191,23,@1'; alter system kill session'192,11,@1'; alter system kill session'199,6839,@1'; alter system kill session'200,1959,@1'; alter system kill session'201,1694,@1';