Thursday, September 28, 2023

sys username and password invalid

 SYS USERNAME and PASSWORD INVALID:


check select * from v$pwfile_users;

it should give value for sys user if not create password file in $ORACLE_HOME/dbs


cd  <ORACLE_HOME>/dbs

CREATE PASSWORD FILE

$ORACLE_HOME/bin/orapwd file=<OH>/dbs/orapw<sid> password=<password> entries=<max entries number>;


Using the sys user and the password which is set in the password file to logging into the dbconsole

Make sure the DB parameter REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

SQL> show parameter REMOTE_LOGIN_PASSWORDFILE

NAME                                   TYPE     VALUE
------------------------------------ -----------  ------------------------------
remote_login_passwordfile       string       EXCLUSIVE


check    sqlnet.ora below enters: 

# sqlnet.ora Network Configuration File: /data/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora

# Generated by Oracle configuration tools.


NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)


SQLNET.EXPIRE_TIME=10


NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

SQLNET.ALLOWED_LOGON_VERSION_SERVER=8

SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8



now login with sys user it should login.


Tuesday, September 19, 2023

Setup glogin.sql

  

Setup glogin.sql in Oracle


Setup glogin.sql in Oracle

Let's take you want to execute some sql commands every time you login to SQL*PLUS. It would be so hard to run those commands manually whenever you start SQL*PLUS. With glogin.sql you can specify the commands you want to run every time you invoke SQL*PLUS.


Any query, script, parameter, PL/SQL code etc, you can simply put under glogin.sql file and SQL*PLUS will first execute glogin.sql before allowing you to query database.


I would like to display below message every time a user logs into the database


SQL*Plus: Release 12.1.0.2.0 Production on Tue Sep 19 14:47:05 2023


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



Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options



Hello

------------------------------------------------

Welcome, you are connected to MOMDEV database



setup glogin.sql in oracle - testdb database 

Open the glogin.sql file

vi $ORACLE_HOME/sqlplus/admin/glogin.sql


Put below query at the end of the file

select 'Welcome, you are connected to '||name||' database' "Hello" from v$database;

Save and close. That's it, now whenever you login to SQL*PLUS, you will be greeted with a nice welcome message!