i have an application which creates database schema's (Oracle 10g) for the users. The access to these schema's expires after a certain time. These schema's can be as large as 2GB in size. The actual operational data for the application is comparatively less.
To keep the database size low, what would be the best approach to archive this database schema's considering that these can be restored when required to be accessed by the user.
I am thinking if the following approach:
Convert the Schema in .csv files for each table and then compress the files (zip). Using csv can be an advantage considering its easy to convert csv to/from DB tables.
Please let me know if there is any better approach to do the same. The main aim here is to save the operational DB space.
Use Data Pump Export and Data Pump Import instead of building a custom tool. Exporting and importing data and metadata is not a trivial task. Data Pump was built for situations like this, it is already including with Oracle, and it has many advanced features.
Here's a very simple example of archiving a schema using data pump.
Create a directory to hold the export. This is only required once per database.
SQL> create directory export_directory as 'C:\test';
Directory created.
Create a test schema and sample data.
SQL> create user test_user identified by test_user;
User created.
SQL> alter user test_user quota unlimited on users;
User altered.
SQL> create table test_user.table1 as select 1 a from dual;
Table created.
Export Data Pump.
C:\test>expdp jheller#orcl12 directory=export_directory dumpfile=test_user.dmp schemas=test_user
Export: Release 12.1.0.1.0 - Production on Thu Jun 12 22:33:25 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "JHELLER"."SYS_EXPORT_SCHEMA_01": jheller/********#orcl12 directory=export_directory dumpfile=test_user.dmp schemas=test_user
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
. . exported "TEST_USER"."TABLE1" 5.031 KB 1 rows
Master table "JHELLER"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for JHELLER.SYS_EXPORT_SCHEMA_01 is:
C:\TEST\TEST_USER.DMP
Job "JHELLER"."SYS_EXPORT_SCHEMA_01" successfully completed at Thu Jun 12 22:34:35 2014 elapsed 0 00:00:56
Compress the file.
There is a data pump option to compress the data but it requires the Advanced Compression option. Instead of paying thousands of dollars per core I recommend downloading
one of a thousand free software programs that have been compressing data for decades.
C:\test>zip test_user.zip test_user.dmp
adding: test_user.dmp (172 bytes security) (deflated 90%)
C:\test>dir
Volume in drive C is OS
Volume Serial Number is 660C-91D8
Directory of C:\test
06/12/2014 10:37 PM <DIR> .
06/12/2014 10:37 PM <DIR> ..
06/12/2014 10:34 PM 1,435 export.log
06/12/2014 10:34 PM 212,992 TEST_USER.DMP
06/12/2014 10:37 PM 21,862 test_user.zip
3 File(s) 236,289 bytes
2 Dir(s) 689,950,937,088 bytes free
Drop the user.
SQL> drop user test_user cascade;
User dropped.
SQL> select count(*) from test_user.table1;
select count(*) from test_user.table1
*
ERROR at line 1:
ORA-00942: table or view does not exist
Import the user.
C:\test>impdp jheller#orcl12 directory=export_directory dumpfile=test_user.dmp
Import: Release 12.1.0.1.0 - Production on Thu Jun 12 22:41:52 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Password:
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "JHELLER"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "JHELLER"."SYS_IMPORT_FULL_01": jheller/********#orcl12 directory=export_directory dumpfile=test_user.dmp
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "TEST_USER"."TABLE1" 5.031 KB 1 rows
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "JHELLER"."SYS_IMPORT_FULL_01" successfully completed at Thu Jun 12 22:42:18 2014 elapsed 0 00:00:19
Check the data.
SQL> select count(*) from test_user.table1;
COUNT(*)
----------
1
Related
I have developed an Oracle pro*C/C++ library that provides an API to other applications to read data from database tables and insert/update data in the tables. Recently a customer reported that the API did not return any error when underlying file systems (ASM) that hold tables spaces went down for a few days! This must be due to caching data by Oracle instance.
My question is this: Can we make Oracle return error, without affecting its caching scheme, for any read/write access to a table immediately after its table space is found to be not accessible due to corruption or any disk related errors?
I did a small experiment to simulate the customer's problem. I have created a new directory on my Linux system. Created a table space in it and created a table to use the table space. Inserted a few rows using sqlplus and fetched rows from the table and verified results. They are OK. Then I renamed table space file to some other file to simulate missing/corruption of the table space. Oracle still returned rows even though physical table space was missing. I could even insert a few rows successfully and commit went through without any error(probably this may fail for large number of inserts). However, I could not shut down the database instance. Once I aborted the instance, start up failed with an error saying the table space could not be identified/locked. After that sqlplus could not connect to the database. But my requirement is to get an error for any DML operation if the table space file found to be missing or corrupted.
Following is my experiment:
Created a directory for a new tablespace
[root#mvsLTOraLin u01]# mkdir /orats
[root#mvsLTOraLin u01]# chown oracle /orats
[root#mvsLTOraLin u01]# chgrp oinstall /orats
Created a table space using sysdba user as following:
SQL> create tablespace orats datafile '/orats/ots1.dbf' size 5M;
Tablespace created.
[root#mvsLTOraLin orats]# pwd
/orats
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 ots1.dbf
Created a table in the table space using fis_admin user and inserted 3 rows:
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 17:56:50 2015
Copyright (c) 1982, 2009, 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> create table tbl1(c1 int not null primary key, c2 varchar2(100)) tablespace orats;
Table created.
SQL> insert into tbl1 values(1, 'one');
1 row created.
SQL> insert into tbl1 values(2, 'two');
1 row created.
SQL> insert into tbl1 values(3, 'three');
1 row created.
SQL> select * from tbl1;
C1
----------
C2
--------------------------------------------------------------------------------
1
one
2
two
3
three
Renamed table space file from ots1.dbf to gone.dbf to simulate corruption of the table space.
[root#mvsLTOraLin orats]# date
Sat Jul 11 18:03:00 IST 2015
[root#mvsLTOraLin orats]# mv ots1.dbf gone.dbf
[root#mvsLTOraLin orats]# ls -l
total 5128
-rw-r-----. 1 oracle oinstall 5251072 Jul 11 17:53 gone.dbf
Selected data from sqlplus which is still connected
SQL> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.05.20.525276 PM +05:30
2
11-JUL-15 06.05.20.525276 PM +05:30
3
11-JUL-15 06.05.20.525276 PM +05:30
Retrieved data even though table-space disappeared.
This shows Oracle is returning from its cache.
Restarted sqlplus and queried. Still server did not realise that its table space is missing!
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-4.1$
-bash-4.1$ sqlplus fis_admin/fis_admin#fisdb
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:07:24 2015
Copyright (c) 1982, 2009, 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> select c1, current_timestamp from tbl1;
C1
----------
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
1
11-JUL-15 06.07.42.014083 PM +05:30
2
11-JUL-15 06.07.42.014083 PM +05:30
3
11-JUL-15 06.07.42.014083 PM +05:30
Tried to shutdown the instance
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 11 18:08:42 2015
Copyright (c) 1982, 2009, 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> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL>
It failed as expected.
Tried to insert a row.
SQL> insert into tbl1 values(4, 'four');
1 row created.
Surprise! The insert was successful. It must may fail for many inserts.
Forced shutdown
SQL> shutdown
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown immediate
ORA-01116: error in opening database file 5
ORA-01110: data file 5: '/orats/ots1.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> quit
Restarted instance
SQL> startup;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 742395736 bytes
Database Buffers 318767104 bytes
Redo Buffers 5554176 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/orats/ots1.dbf'
Error is shown as expected.
Tried access to tbl1:
SQL> select c1, current_timestamp from tbl1;
select c1, current_timestamp from tbl1
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
Failed as expected.
So, is there a way to make Oracle return error on next access to the table for reading or writing even though data may be returned from cache?
I am unable to login to 'postgres' database as 'postgres' user.
OS : REHL Server release 6.3
Postgresql version: 8.4
There is a Database 'jiradb' which is used as a Backend for JIRA 6.0.8.
When I give the command
[root ~]#psql postgres postgres
Password for user postgres: *******
psql: FATAL: could not open relation with OID 2696
How do I fix this error and login to 'postgres' database. Please ask me if you need more details. I am new to postgres DB.
Thanks.
Your postgres database is damaged. oid 2696 is a system reserved oid, so it's a system table, and their oids are stable across databases and across versions. Looking it up on my 9.4, it's:
regress=> select relname from pg_class where oid = 2696;
relname
----------------------------------
pg_statistic_relid_att_inh_index
(1 row)
regress=> \d pg_statistic_relid_att_inh_index
Index "pg_catalog.pg_statistic_relid_att_inh_index"
Column | Type | Definition
------------+----------+------------
starelid | oid | starelid
staattnum | smallint | staattnum
stainherit | boolean | stainherit
unique, btree, for table "pg_catalog.pg_statistic"
so you have a missing file in the data directory for the index pg_statistic_relid_att_inh_index on the system table pg_catalog.pg_statistic.
This should not happen. You have at lest limited data corruption in your datadir.
Your first action should be to stop the database and make a full filesystem-level copy of the entire data directory, per PostgreSQL wiki - corruption.
Then check for possible causes. Recent disk issues? Unexpected/sudden shutdowns followed by fsck, possibly on a system with a non-crashsafe file system, unsafe mount options (e.g. ext3/ext4 data=writeback), unsafe configurations like ext[34]-on-LVM-on-md with barriers on older kernels, etc. Also make sure you're on the latest 8.4 point release.
Only once you have made a full file system level copy of the data directory to safe read-only storage, start the database back up (but not the applications that use it) and see if you can connect to jiradb e.g. psql jiradb. If you can, promptly perform a pg_dump of jiradb and any other databases with data of value.
Do not keep on using the damaged data directory. Now is a good time to do a dump and reload - do a pg_dumpall --globals-only, a pg_dump -Fc of each database, then move the datadir aside, re-initdb, and start back up with a clean install. You might even want to upgrade to a less ancient PostgreSQL at the same time.
Note that it is generally possible to fix issues like this in-place. In this case, if your damaged database wasn't the unimportant-and-usually-empty postgres database, you could start PostgreSQL up in single-user mode with system indexes disabled, then REINDEX the damaged index.
Basically Im trying to get the output of 'DESC HR.EMPLOYEES' via command line.
I have created a file called 'file.sql'
DESC hr.employees;
exit;
Then I execute this on unix command line:
sqlplus username/password #file.sql
My output looks like this, however I want to eliminate all extra messages and want to see only the relevant query result. Any way this is possible? Basically someway to do a silent login / logoff.
SQL*Plus: Release 12.1.0.1.0 Production on Mon Sep 15 19:04:53 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 7 days
Last Successful login time: Mon Sep 15 2014 19:04:06 -04:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
I used the -s option with sqlplus. and that eliminated most of the unwanted messages. But I still get ERROR: ORA-28002: the password will expire within 7 days
You do clearly need to change the password, but if you have a scenario where you need to be able to run a particular script in the meantime, it is possible to hide that message; but you have to move the credentials into the file. (Supplying them on the command line is insecure anyway). So file.sql would become:
set termout off
connect username/password
set termout on
desc hr.employees;
exit;
And you'd run it as:
sqlplus -s /nolog #file
The /nolog means it won't automatically attempt to connect, and when it does so from within the script the output from the connection command is hidden.
Of course, this would hide any other messages related to the account or database availability which would make understanding a failure hard; and you probably really want to be told about the pending expiry so you can change the password - otherwise you'll come to run this a week later and find the account is actually expired, which isn't something you can fix yourself. (Since your example is from the 15th, your account may already have expired, or had its password reset, of course).
Another minor wrinkle with this is that any SQL commands in your login.sql or glogin.sql will show an SP2-0640 error as they will try to run before you are connected.
Just because something is possible doesn't mean it's a good idea, and the potential issues almost certainly outweigh any advantages. So really, when you see the warning, change the password.
This error message ...
ORA-28002: the password will expire within 7 days
...means what it says. The account's password is set to expire and that user will not be able to login within the next week.
You want to get rid of the message? Simple: change the password.
If that solution is undesirable for any reason (I don't know how you use the account) you will need to persuade the DBA to unexpire it. That is probably less simple.
If you want to get rid off the PASSWORD EXPIRY message, then you can set the PASSWORD_LIFE_TIME limit to unlimited. Follow these steps :
SQL> SELECT PROFILE FROM DBA_USERS WHERE USERNAME='SCOTT'
2 /
PROFILE
------------------------------
DEFAULT
SQL>
SQL> SELECT RESOURCE_NAME,
2 LIMIT
3 FROM DBA_PROFILES
4 WHERE PROFILE ='DEFAULT'
5 AND RESOURCE_NAME='PASSWORD_LIFE_TIME'
6 /
RESOURCE_NAME LIMIT
------------------------------ ------------------------------
PASSWORD_LIFE_TIME 180
For your profile, execute :
alter profile <profile_name> limit password_life_time UNLIMITED;
You shouldn't be getting the message again.
Adding -S flag worked for me.
sqlplus -S username/pass#server #sample.sql
In SQL*plus i can't open the databse which is already created in my computer....
the error it shows that "the database is not yet open"
and i want to know that in what command is suitable to open database.
I assume you're getting an error such as ORA-01219: database not open: queries allowed on fixed tables/views only. In that case, the fix is to connect as SYS and execute ALTER DATABASE OPEN:
C:\Users\Luke>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sun Mar 17 10:31:40 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> select count(*) from user_tables;
select count(*) from user_tables
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> alter database open;
Database altered.
SQL> select count(*) from user_tables;
COUNT(*)
----------
935
If you get an error ORA-01507: database not mounted when you run ALTER DATABASE OPEN, run ALTER DATABASE MOUNT before ALTER DATABASE OPEN.
There might a reason why the database isn't open and/or mounted. Perhaps it failed to open? In that case, ALTER DATABASE OPEN is likely to result in an error other than ORA-01507. If so, the folks on https://dba.stackexchange.com/ should be able to help you.
When trying to connect to an ORACLE user via TOAD (Quest Software) or any other means (Oracle Enterprise Manager) I get this error:
ORA-011033: ORACLE initialization or shutdown in progress
After some googling, I found the advice to do the following, and it worked:
SQL> startup mount
ORACLE Instance started
SQL> recover database
Media recovery complete
SQL> alter database open;
Database altered
Here is my solution to this issue:
SQL> Startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> Show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string C:\APP\USER\ORADATA\ORACLEDB\C
ONTROL01.CTL, C:\APP\USER\FAST
_RECOVERY_AREA\ORACLEDB\CONTRO
L02.CTL
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT'
2
SQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=
b.group# and b.status='CURRENT';
MEMBER
--------------------------------------------------------------------------------
GROUP# STATUS
---------- ----------------
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
3 CURRENT
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1904054272 bytes
Fixed Size 2404024 bytes
Variable Size 570425672 bytes
Database Buffers 1325400064 bytes
Redo Buffers 5824512 bytes
Database mounted.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 4234808 generated at 01/21/2014 18:31:05 needed for thread 1
ORA-00289: suggestion :
C:\APP\USER\FAST_RECOVERY_AREA\ORACLEDB\ARCHIVELOG\2014_01_22\O1_MF_1_108_%U_.AR
C
ORA-00280: change 4234808 for thread 1 is in sequence #108
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
C:\APP\USER\ORADATA\ORACLEDB\REDO03.LOG
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
Database altered.
And it worked:
I had a similar problem when I had installed the 12c database as per Oracle's tutorial . The instruction instructs reader to create a PLUGGABLE DATABASE (pdb).
The problem
sqlplus hr/hr#pdborcl would result in ORACLE initialization or shutdown in progress.
The solution
Login as SYSDBA to the dabase :
sqlplus SYS/Oracle_1#pdborcl AS SYSDBA
Alter database:
alter pluggable database pdborcl open read write;
Login again:
sqlplus hr/hr#pdborcl
That worked for me
Some documentation here
This error can also occur in the normal situation when a database is starting or stopping. Normally on startup you can wait until the startup completes, then connect as usual. If the error persists, the service (on a Windows box) may be started without the database being started. This may be due to startup issues, or because the service is not configured to automatically start the database. In this case you will have to connect as sysdba and physically start the database using the "startup" command.
I used a combination of the answers from rohancragg, Mukul Goel, and NullSoulException from above. However I had an additional error:
ORA-01157: cannot identify/lock data file string - see DBWR trace file
To which I found the answer here: http://nimishgarg.blogspot.com/2014/01/ora-01157-cannot-identifylock-data-file.html
Incase the above post gets deleted I am including the commands here as well.
C:\>sqlplus sys/sys as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 30 19:07:16 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 778387456 bytes
Fixed Size 1384856 bytes
Variable Size 520097384 bytes
Database Buffers 251658240 bytes
Redo Buffers 5246976 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 11 – see DBWR trace file
ORA-01110: data file 16: 'E:\oracle\app\nimish.garg\oradata\orcl\test_ts.dbf'
SQL> select NAME from v$datafile where file#=16;
NAME
--------------------------------------------------------------------------------
E:\ORACLE\APP\NIMISH.GARG\ORADATA\ORCL\TEST_TS.DBF
SQL> alter database datafile 16 OFFLINE DROP;
Database altered.
SQL> alter database open;
Database altered.
Thanks everyone you saved my day!
Fissh
The issue can also be due to lack of hard drive space. The installation will succeed but on startup, oracle won't be able to create the required files and will fail with the same above error message.
I hope this will help somebody, I solved the problem like this
There was a problem because the database was not open.
Command startup opens the database.
This you can solve with command alter database open
in some case with alter database open resetlogs
$ sqlplus / sysdba
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 624952632 bytes
Database Buffers 436207616 bytes
Redo Buffers 3952640 bytes
Database mounted.
Database opened.
SQL> conn user/pass123
Connected.
I faced the same problem. I restarted the oracle service for that DB instance and the error is gone.
What worked for me is that i hadn't set the local_listener, to see if the local listener is set login to sqlplus / as sysdba, make sure the database is open and run the following command
show parameter local_listener, if the value is empty, then you will have to set the local_listener with the following SQL command ALTER SYSTEM SET LOCAL_LISTENER='<LISTENER_NAME_GOES_HERE>'