SQL query in unix shell script - unix

I have written a code that will give me the required output after executing it.
Below is the code:
#!/bin/ksh
sqlplus / << !EOF!
set verify off
set heading off
set pagesize 0
set feedback off;
select * from account where account_name='23553558101';
exit;
!EOF!`
The problem is that I'm getting all the non-required stuffs too, but I need the output only not other things along with that.
Below is the output I'm getting:
$ ./sqltest
SQL*Plus: Release 10.2.0.1.0 - Production on Mon May 29 17:32:52 2017
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining Scoring Engine and Real Application Testing options
17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > 56566309 23553558101 20-05-2017 05:41:00 57194135 20000184 64,56
20-05-2017 00:00:00 340393871 338845845 500 0
0
17:32:52 OPS$SP1ITA1B#SVITPRD1 > 17:32:52 OPS$SP1ITA1B#SVITPRD1 > Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining Scoring Engine and Real Application Testing options

When you are using sqlplus in a shell script is better to log in using the silent mode "sqlplus -s" to supress the login messages and also to remove the sql prompt "sql >".
Further more, you need to change some variables like:
heading - it will not display the head of the query result(the name of the columns to be more precise)
set heading off
feedback - it will not return the number of rows after a query select.
set feedback off
verify - is used to display the values in case you have substitution variables
set verify off
The columns presented above are ON by default so it is better to switch them off if you want a clean display (just the result) and also it is mandatory in my opionion if the result of your sqlplus will be collected by a shell variable.
You can check the manual for more information about sqlplus system variables:
https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#SQPUG060

Related

How to check the NebulaGraph Database version?

As title, I want to know the NebulaGraph Database version.
I use nebula-console here.
[root]# ./nebula-console -addr 192.168.8.136 -port 9669 -u root -p nebula
Welcome to Nebula Graph!
(root#nebula) [(none)]> use basketballplayer
Execution succeeded (time spent 2206/2702 us)
Mon, 12 Dec 2022 06:09:16 UTC
As NebulaGraph is distributed, thus there is technically no version for the "database" but for each component, we could use SHOW HOSTS <type_of_the_process> to get this info since 2.x from the client side:
SHOW HOSTS STORAGE
SHOW HOSTS GRAPH
SHOW HOSTS META
SHOW HOSTS AGENT
There will be a version column of the output then.
Of course, from the server side, the binary itself supports checking the version like this:
/usr/local/nebula/bin/nebula-graphd --version
nebula-graphd version 2022.03.30-nightly, Git: 1e68162, Build Time: Mar 31 2022 02:31:25
This source code is licensed under Apache 2.0 License.

Why the expdp can't see this table? It's there?

Does anyone know why this is happening? I can select the table but
can't export it.
C:\>sqlplus myschema/myschema
SQL*Plus: Release 12.1.0.2.0 Production on Mon Aug 1 14:43:45 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Mon Aug 01 2016 14:42:51 -04:00
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 opt
ions
SQL> select * from product;
ID NAME
---------- --------------------
1 sample_product_name
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64
bit Production
With the Partitioning, OLAP, Advanced Analytics, and Real Application Testing opt
ions
C:\>expdp myschema/myschema#oradev tables=product directory=DATA_PUMP_DIR dumpfi
le=expdp_myschema.dmp logfile=expdp_myschema.log
Export: Release 12.1.0.2.0 - Production on Mon Aug 1 14:44:16 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. 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 opt
ions
WARNING: Oracle Data Pump operations are not typically needed when connected to
the root or seed of a container database.
Starting "MYSCHEMA"."SYS_EXPORT_TABLE_01": myschema/********#oradev tables=prod
uct directory=DATA_PUMP_DIR dumpfile=expdp_myschema.dmp logfile=expdp_myschema.l
og
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
**ORA-39166: Object MYSCHEMA.PRODUCT was not found** or could not be exported or imp
orted.
ORA-31655: no data or metadata objects selected for job
Job "MYSCHEMA"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at Mon Aug 1 14:4
4:18 2016 elapsed 0 00:00:01
Add parameter CONTENT=ALL at the end of your expdp command line,like this:
expdp myschema/myschema#oradev tables=product directory=DATA_PUMP_DIR dumpfi le=expdp_myschema.dmp logfile=expdp_myschema.log CONTENT=ALL
and execute it.

Oracle 11g XE installation on docker RHEL 7 image

While installing oracle 11g XE on docker i am getting the error.
Following are the output:-
/etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
This will configure on-boot properties of Oracle Database 11g Express
Edition. The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts. Press to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
Specify a port that will be used for the database listener [1521]:1521
Specify a password to be used for database accounts. Note that the same
password will be used for SYS and SYSTEM. Oracle recommends the use of
different passwords for each database account. This can be done after
initial configuration:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y
Starting Oracle Net Listener...Done
Configuring database...
Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details
[root#b7c63c4e1da8 Disk1]# cd /u01/app/oracle/product/11.2.0/xe/config/log
[root#b7c63c4e1da8 log]# ls
CloneRmanRestore.log cloneDBCreation.log postDBCreation.log postScripts.log
[root#b7c63c4e1da8 log]# cat CloneRmanRestore.log
ORA-00845: MEMORY_TARGET not supported on this system
select TO_CHAR(systimestamp,'YYYYMMDD HH:MI:SS') from dual
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
declare
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
select TO_CHAR(systimestamp,'YYYYMMDD HH:MI:SS') from dual
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
One of the possible solution that I got was to mount the temp file to provide extra space to it which only contains 6GB approx in the docker. But i am unable to mount the memory in docker.
Got the solution for the same :-
we have to modify the files init.ora and initXETemp.ora at the path /u01/app/oracle/product/11.2.0/xe/config/scripts
with the values :-
###########################################
# Miscellaneous
###########################################
compatible=11.2.0.0.0
diagnostic_dest=/u01/app/oracle
#memory_target=1073741824
pga_aggregate_target=200540160
sga_target=601620480
You may encounter
ORA-00845: MEMORY_TARGET not supported on this system
when starting Oracle DB in an unprivileged container. Try running the container with the --privileged flag, e.g.
docker run --name oracle12 --hostname oracledb --privileged local/oracle12:12.1.0.2

ORA-12560: TNS:protocol adaptor error after delete one database

i have oracle11g desktop. For my project I create 3 databases via configuration assistant tools. Then I delete one of them
and after this I have the error: ora-12560.
By mistake both of my databases have the same pasword,
for example: when i want to connect one of these data bases with system user, i have one pasword and perhaps the databases dont know connect which one.
I start all services
set oracle_sid=orcl.
I run lsnrctl
tnsping check tansname.ora & my listener.ora
and I logon with sysdba#oracle_sid
but i have this error again
pleas help me
tnx
sounds like the database is not up. you probably restarted your machine and the instance is not set to autostart
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
scott%ORA10GR1> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1
The OracleServiceORA10GR1 service is stopping.........
The OracleServiceORA10GR1 service was stopped successfully.
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
C:\Documents and Settings\tkyte>net start oracleserviceora10gr1
The OracleServiceORA10GR1 service is starting..........
The OracleServiceORA10GR1 service was started successfully.
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
scott%ORA10GR1>
I have got the same error after delete a db (in the window enviroment) and I resolved as following
the first way:
C:> SET ORACLE_SID = SID NAME
the second way:
Use regedit locate to path: HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_HOME_NAME
update ORACLE_SID =
refer at: https://docs.oracle.com/database/121/ADMQS/GUID-EC18C4A6-3BA5-4C14-9D76-B0DD62FEFFF2.htm#ADMQS12369

Interesting variation of the TNSPING Message 3511 error

I have the following problem with Oracle 11g TNSPING utility: fresh 11g client installation, ORACLE_HOME set up properly, TNS_ADMIN also set, msb files available in desired location, readable by the user that invokes TNSPING. Connection to the database works, sqlplus can be used to connect. TNSPING, however, fails badly. See attached log:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\USERNAME>set ORACLE_HOME=C:\Work\Software\Oracle\product\11.2.0\client_1
C:\Users\USERNAME>set TNS_ADMIN=%ORACLE_HOME%\network\admin
C:\Users\USERNAME>set NLS_LANG=ENGLISH_POLAND.EE8MSWIN1250
C:\Users\USERNAME>dir %TNS_ADMIN%\tnsnames.ora
Volume in drive C is XXX
Volume Serial Number is YYY
Directory of C:\Work\Software\Oracle\product\11.2.0\client_1\network\admin
2013-03-19 12:26 358 tnsnames.ora
1 File(s) 358 bytes
0 Dir(s) 59 082 616 832 bytes free
C:\Users\USERNAME>dir %ORACLE_HOME%\network\mesg\tns*.msb
Volume in drive C is XXX
Volume Serial Number is YYY
Directory of C:\Work\Software\Oracle\product\11.2.0\client_1\network\mesg
2010-03-31 07:01 53 248 tnspl.msb
2010-03-31 07:01 47 104 tnsus.msb
2 File(s) 100 352 bytes
0 Dir(s) 59 082 616 832 bytes free
C:\Users\USERNAME>sqlplus <USER>/<PASSWORD>#<DATABASE>
SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 19 14:36:34 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
SQL> exit
Disconnected from Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
C:\Users\USERNAME>tnsping <DATABASE>
TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 19-MAR-2013 14:37:52
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Message 3511 not found; No message file for product=NETWORK, facility=TNSMessage 3512 not found; No message file for product=NETWORK, facility=TNSMessage 3513 not found; No message file for product=NETWORK, facility=TNSMessage 3509 not found; No message file for product=NETWORK, facility=TNS
Please note: I had to replace all the user credentials, database name, etc., due to security considerations.
Can you help me, please, troubleshoot the issue? I have read all the other StackExchange topics related to TNSPING failure, but each of the solutions (set up ORACLE_HOME, reinstall, make sure registry points to proper home, check msb files) has failed me...
Thanks in advance!

Resources