unable to execute SQL Statement from Putty - oracle

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

Related

PL/SQL from Oracle SQL Developer connecting to DB2

I have successfully connected to a DB2 database from Oracle SQL Developer 19.4.0.354 using the DB2 ODBC driver.
SQl scripts work just fine.
Now I also want to execute PL/SQL scripts but simple sample script fails.:
set serveroutput on
DECLARE
message varchar2(20):= 'Hello, World!';
BEGIN
dbms_output.put_line(message);
END;
It fails in such a way that PL/SQL code does not seem to be accepted at all:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=DECLARE
message varchar2(20):= 'Hell;BEGIN-OF-STATEMENT;<create_view>, DRIVER=4.26.14
Is PL/SQL generally supported in this setup?
When using the Oracle-compatibility mode of Db2-LUW, it is necessary to:
set the Db2-registry-variable DB2_COMPATIBILITY=ORA with the db2set command.
bounce the Db2-instance with the db2stop and db2start commands, so the registry variable becomes effective.
create a new database after both of the above steps are completed (using the db2 create database command ), so that Oracle specific datatypes and other features become available.
If you only change the registry variable and bounce the Db2-instance but use a pre-existing database then you will not get all of the implemented Oracle compatibility features! This is documented in the Db2-Knowledge-Centre online.
With currently shipping Db2-LUW versions, you cannot retrofit the Oracle compatibility on to a previously created database.

How to create a table in 18c express edition

I just finished installing oracle 18c express edition on windows 8 laptop. During the installations, I did not enter any user name. I entered my password though.
At the end of the installation, I get this screen:
I connected Oracle database using sql plus as follows:
SQL> / as sysdba
I also entered the following commands in sql plus and all have worked. I was just following youtube tutorial without understanding everything.
SQL>alter pluggable database all open;
SQL>alter pluggable database all save state ;
SQL>select name from v$pdbs;
SQL> connect sys/oracle#localhost:1521/XEPDB1 as sysdba;
SQL> alter user hr identified by hr;
SQL> alter user hr account unlock;
SQL>connect hr/hr#localhost:1521/XEPDB1;
SQL> select * from employees;
SQL> CREATE TABLE TEST1 (CUSID NUMBER(10) NOT NULL);
This is the first time I am doing it. I tried to connect to a database using SYS as the user name and the password but did not connect.
SQL> Enter user name: SYS;
Enter password: Welcome1
SYS - During the installation, it said sys, system, and pdbadmin accounts. So I assume sys could be one of the user names.
Password - I entered the same password I used at the time of installation. I can connect to the database using / as sysdba. But I am not sure what this code meaning and what the user name and password and what database it is trying to connect. What would be the database name, user name and password?
Update 1
I created a connection in sql developer. Below shows the connection properties.
I created a table(sqldev2) in sql developer, inserted rows, and selected the data just fine.
Next, I went to sql plus and tried to select the same data from sqldev2 table but it shows no rows selected. I am assuming sql plus and sql developer may be pointing to two different databases?
How can I tell which database I am connected using the sql developer?
How can I connect to the same database using the sql plus?
This way I can work on the same database using the sql plus and sql developer.
Update 2
In Eclipse IDE, I had this code to connect to database. After that, I created a table (testtble) in Eclipse.
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver Loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521/xe", "sys as sysdba","pw");
In SQL Plus, I connected to the db using "/ as sysdba". After that, I also tried to select * from testtble but it shows no table. I am assuming sql plus might be pointing to something different than what I used in eclipse. How should I connect to the database from SQL plus so I could see the table "testtble" in sql plus?
To check in which pluggable database you are currently connected in SQL*Plus use:
show con_name
If you connect to Oracle using a connect string that is using a database service mapped to a pluggable database (PDB), you will be connected directly to the related PDB.
Try different connections strings and check with show con_name.

how to connect oracle database from unix without showing password

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.

Connected to Pluggable Database - Cannot See Any Tables - SQL*PLUS

I am using sqlplus to connect to a pluggable database that is running on my localhost. However, when I connect I cannot see any of the tables from the major schemas.
Does anyone know how to trouble shoot this type of problem? When I connect using PL/SQL Developer however I am able to see the tables. I am connecting to the pluggable database using sql*plus like so:
sqlplus localhost:1521/services.domain as sysdba
When I try to select a table I see an error that the table or view does not exist. When I connect with PL/SQL developer like so, shown below in Figure 1, I do not have the problem of not being able to select any tables.
Figure 1: Logging into PL/SQL Developer

What Oracle setting prevents open cursors from closing?

I have two Oracle 11G installations. I can run a script that imports a 37MB database into one of them with no problems (installation A). In the other (installation B), when I run the exact same script with the exact same file it gets "ORA-01000: maximum open cursors exceeded". I increased the max open cursors to 20,000 but when the script gets to row 20,000 then it stops with the same ORA-01000 error. The installation that is working has max open cursors set to 300.
Obviously there is no problem with the script or the SQL because it works in one Oracle database. So there must be a setting in the other Oracle instance that prevents open cursors from closing. What could it be?
Installation A works.
Database = Oracle Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options. Driver = Oracle JDBC driver 11.2.0.1.0.
Installation B does not work.
Database = Oracle Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options. Driver = Oracle JDBC driver 11.2.0.3.0.
I would recommend checking what cursors are open in a session. If you see 10.000 statements, all alike, with open cursors, there is something wrong in the code.
I myself find the easiest way to do this:
connect sys
alter system flush shared_pool; /* Removes everything can be finished, the trees hinder my view of the forest. */
/* Overall overview. */
select *
from v$sqlarea
/* Open cursors per session. */
select *
from v$open_cursor

Resources