Wednesday, February 8, 2017

how to create a user in oracle 11g and grant permissions, account unlock

CREATE USER username IDENTIFIED BY password;
GRANT CONNECT TO username;
GRANT SELECT,INSERT,UPDATE,DELETE on schema.table TO username;
 esvel
GRANT EXECUTE on schema.procedure TO username;
esvel
GRANT ALL privileges TO username;


CREATE USER <<username>> IDENTIFIED BY <<password>>; -- create user with password
GRANT CONNECT,RESOURCE,DBA TO <<username>>; -- grant DBA,Connect and 
Resource permission to this user(not sure this is necessary 
if you give admin option)
GRANT CREATE SESSION TO <<username>> WITH ADMIN OPTION; --Give admin option to user
GRANT UNLIMITED TABLESPACE TO <<username>>; -- give unlimited tablespace grant

http://stackoverflow.com/questions/9447492/how-to-create-a-user-in-oracle-11g-and-grant-permissions



Resolving ORACLE ERROR:ORA-28000: the account is locked

After installation of Oracle10g, there was a problem ..couldnt login using SQL+. None of the accounts(scott/tiger) worked . At last a quick web search gave the solution . Here is what it is:

From your command prompt, type
sqlplus "/ as sysdba"
Once logged in as SYSDBA, you need to unlock the SCOTT [or maybe SYSTEM] account
SQL> alter user scott account unlock;
SQL> grant connect, resource to scott;


example in my PC: 

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\BOR>sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 14 08:56:49 2017

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter user SYSTEM unlock;
alter user SYSTEM unlock
                  *
ERROR at line 1:
ORA-00922: missing or invalid option


SQL> ALTER USER SYSTEM ACCOUNT UNLOCK;

User altered.

SQL> ALTER USER SYSTEM IDENTIFIED BY password;

User altered.

SQL>

No comments: