i am trying to connect Oracle database from Linux server where environment variables and tnsnames.ora cannot be modified.
I am using following code to connect which is working fine and i am able to connect database using sqlplus.
export ORACLE_HOME=/opt/oracle/product/112030_cl_64/cl
export PATH=/opt/oracle/product/112030_cl_64/cl/bin:$PATH
sqlplus myuser/mypass#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(Host=x)(Port=x)))(CONNECT_DATA=(SERVICE_NAME=x)))
Now i am not able to find any solution how can i execute it so that i don't need to execute it manually every time and i don't want to share the password with anyone else. i want to connect db using sqlplus from a shell script to spool data.
any lead would be appreciable. Thanks in advance.
The cleanest way is to use Oracle Wallet to store database passwords and so that your scripts can use them.
Otherwise if you can login as the oracle product owner ("oracle" most of the time) and it belong to the "dba" group you can connect as sys without typing the password (sqlplus / as sysdba) but it's privileged access, don't use it for business processes.
Omit the password; you'll be prompted to enter it, but it'll be invisible (Windows example, but doesn't matter in this case):
M:\>sqlplus scott#orcl
SQL*Plus: Release 11.2.0.1.0 Production on ╚et Tra 11 13:01:35 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>
That, of course, requires you to type it every time. If it is stored, somewhere, anyone else could see it. Perhaps there is a way, but I don't know it.
Related
When we connect to Oracle database for the first time from SQLPlus command line tool, why do we always connect like this
"sys as sysdba"
Can some one tell me the significance of this?
Why do not we do this in MYSQL?
I am new to Oracle, and this question might sound silly. I am learning using Oracle 11g XE.
SYS and SYSTEM are administrative users, they kind of "own" the database. Data dictionary is stored in SYS schema so - if you screw it up, you'll most probably destroy the database. Therefore, never mess up with it - use it only for necessary administrative tasks. Never touch any SYS owned tables (thinking "if I change this I'll make that happen). Even better, create your own user and grant it DBA privilege - it'll be able to do mostly everything you'd ever want.
SYSDBA is a privilege which is automatically granted to user SYS; it lets it perform high-level administrative tasks (such as backup and recovery or upgrade the database). SYSTEM doesn't have it; that's why you don't specify as sysdba when connecting as SYSTEM.
Furthermore, SYSDBA privilege lets you to connect to database instance although database isn't open yet - and lets you start it up.
Saying that you "always connect as sys as sysdba" - well, you don't have to do that "always". There are other predefined users (such as Scott or HR (Human Resources)) you can use. Default username/password combinations are "scott/tiger" and "hr/hr". Though, they are most probably locked so you can't establish connection. That's why you connect as SYS, unlock those accounts (or create new one(s), depending on what you want to do), and then connect as some other user.
More info here:
SYS and SYSTEM users
SYSDBA and SYSOPER system privileges
Why you don't have that in MySQL? Probably because MySQL isn't Oracle.
Finally, as you're new with Oracle, I'd suggest you to visit & bookmark this page: Oracle Database 10gR2 documentation. Yes, it is kind of "old" and you don't use that version, but it is the last one that separated "Getting Started" and "Most popular" books which makes it easy to find and read. I'd suggest you to read:
Concepts, to learn what Oracle is and how it works
Then, depending on what you'd want to do/be (developer or DBA), pick e.g.
2 day DBA
Administrator's guide
or
SQL reference
PL/SQL user's guide and reference
Application developer's guide - fundamentals
Certainly, you can find these books for database version you do use (11g), it is here: Oracle database online documentation 11g Release 2 (11.2) but - as I said - it is not as nicely presented as 10g.
Good luck with Oracle, enjoy!
I am facing below error/warning when I login to oracle 12 using sqlplus client.
Details :
SQL*Plus: Release 12.1.0.2.0 Production on Fri Nov 8 05:38:11 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
subscriber -1581956048 create failed: Last Successful login time: Fri
Nov 08 2019 05:36:31 -05:00
Connected to: Oracle Database 12c Enterprise Edition Release
12.1.0.2.0 - 64bit Production
Not sure what is subscriber -1581956048 create failed not getting much info on Google.
is anything need to worry about?
Regards
Laks
Issue caused by Fast Application Notification (FAN) for OCI client.
FAN uses Oracle Notification Services (ONS) to publish and subscribe
service for communicating information about all Fast Application Notification (FAN) events.
ONS uses port 6200 by default. If there is a firewall between the
client and the server and port 6200 port is closed then this behavior
is expected
You can use OCI to access Oracle TimesTen In-Memory Database and Oracle TimesTen Application-Tier Database Cache. OCI is an API that provides functions you can use to access the database and control SQL execution. OCI supports the data types, calling conventions, syntax, and semantics of the C and C++ programming languages.
TimesTen and TimesTen Cache support the Oracle Call Interface (OCI) for C or C++ programs.
Starting with Oracle Database Release 12c Release 1 (12.1), Oracle provides an oraaccess.xml file, a client-side configuration file. You can use the oraaccess.xml file to configure selected OCI parameters (some of which are accepted programatically in various OCI API calls), thereby allowing OCI behavior to be changed during deployment without modifying the source code that calls OCI.
Updates to the oraaccess.xml file will not affect already running clients. In order to pick up any updates to the oraaccess.xml file, already running clients need to be restarted.
The oraaccess.xml file is read from the directory specified by the TNS_ADMIN environment variable in regular and instant client installations.
This is the $ORACLE_HOME/network/admin directory on UNIX operating systems and the %ORACLE_HOME%\NETWORK\ADMIN directory on Microsoft Windows operating systems, if TNS_ADMIN is not set in regular client installations.
The oraaccess.xml file has a top-level node with the three elements. One of them is . the tag allows specifying default values for various OCI parameters. Some parameters can only be specified once and hence apply to all connections. These global parameters are described using by some tags. One of them is <events> tag.
Ref .
If you already have an oraaccess.xml file, then convert the part
<events>true</events> to <events>false</events>.
Otherwise create an oraaccess.xml file with the following information in the default_parameters section:
<?xml version="1.0" encoding="ASCII" ?>
<oraaccess xmlns="http://xmlns.oracle.com/oci/oraaccess"
xmlns:oci="http://xmlns.oracle.com/oci/oraaccess"
schemaLocation="http://xmlns.oracle.com/oci/oraaccess
http://xmlns.oracle.com/oci/oraaccess.xsd">
<default_parameters>
<events>false</events>
</default_parameters>
</oraaccess>
put this file under TNS_ADMIN directory, and then restart the SQL*Plus Client.
I'm getting reacquainted with Oracle after several years and Oracle 18 XE is causing some problems. I use SQLDeveloper to connect as the SYSTEM user. Then when I create a new user cpp it says that is an invalid user name. I have to prefix new users with c##, so I created the user c##cpp. The c##cpp user is there under Other Users.
But when I try to create a new connection as the c##cpp user the connection fails. I've also tried creating the connection as just cpp, but that fails too.
What's up with creating users in Oracle 18 XE?
-------Update showing my connection parameters-------
I get the same error if I try to connect with SID XE.
Welcome back to Oracle.
Since you've been away, we added a Multitenant architecture. There is a Container Database - it has common users, with names like C##user.
What you're looking for is the actual database where your data is going to live, that's called a pluggable database. There you would go back to creating users, just like you did back before you left.
Make sure you connect to the pluggable database service. The default would be 'XEPDB1' - connect to THAT as sys or system, and then create your users.
It looks like the problem is that Oracle doesn't like lower case user names. When I put the username in double quotes the connection succeeds:
This is on Oracle 11. I gave up on Oracle 18 XE and installed Oracle 11. What a ridiculous waste of time.
I am trying to Connect Oracle DB and execute SQL statement from Putty rather than TOAD.
I have been able to connect via Putty but sql query not giving answers.
Here are the results blow:
Enter user-name: mkandoi
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Session altered.
mkandoi#LCTIDFT> select count(*) from iordl
2
Every time when I run a query the cursor comes to the next line. where I can write a any thing, but no result is appearing.
Please add semicolon at the end of query
I used to run commands to get Oracle database backup in the old way using 'exp' and 'imp fromuser touser. Now, I am trying to user new command to take backup 'expdp' and 'impdp'.
Steps:
Got backup using expdp with schema parameter on the production server. my username is 'xxx' (Not sure it's fully exported with procedures, function, and view).
Now, on my dev server first I made another user called 'yyy'. I gave directory access to user 'yyy' and trying to run command impdp as below.
C:\impdp yyy/yyy remap_schema=xxx:yyy directory=abc dumpfile=123.dmp logfile=123.log
Now, I am getting an error like the below.
Import: Release 11.1.0.6.0 - Production on Thursday, 24 January, 2013 9:53:58
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining, and Real Application Testing options
ORA-31626: job does not exist
ORA-31633: unable to create master table "yyy.SYS_IMPORT_FULL_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 978
ORA-01031: insufficient privileges
Do I miss any steps? like I have to create a job or anything, not sure. basically, I got backup from one user and need to restore on another user in Oracle.
Please help me.
User yyy will need appropriate privledges necessary to create the objects.
See: privileges required to import objects into your own schema.
http://docs.oracle.com/cd/E11882_01/server.112/e22490/original_import.htm#BABFHCBI
Also:
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_overview.htm#CJAIBFJG
Many Data Pump Export and Import operations require the user to have the DATAPUMP_EXP_FULL_DATABASE role and/or the DATAPUMP_IMP_FULL_DATABASE role. These roles are automatically defined for Oracle databases when you run the standard scripts that are part of database creation. (Note that although the names of these roles contain the word FULL, these roles are actually required for all export and import modes, not only Full mode.)
The DATAPUMP_EXP_FULL_DATABASE role affects only export operations. The DATAPUMP_IMP_FULL_DATABASE role affects import operations and operations that use the Import SQLFILE parameter. These roles allow users performing exports and imports to do the following:
•Perform the operation outside the scope of their schema
I believe, import user donot have permission on import database directory.
In the Import db,
select directory_name,directory_path from dba_directories;
It will show the directory names
sql>grant read,write on directory abc to ;
Robertson
Oracle Database SME
+91-9886321339