My tables aren't showing even though i'm using the same role - sql

I created these tables on sql developer using the default role scott (which I enabled during Oracle 11gs installation)
However when I login from scott using sqlplus the tables don't show at all.
I even tried logging on using connect /as sysdba the tables still don't show up even though I'm connecting via the sysdba role.
I created these tables a week ago and did not initially type the keyword commit when I created these tables however if that was the issue why are they still being displayed on SQL developer every time I log in. Also I think SQL developer auto commits changes when I close it.
And yes these aren't empty tables they do have data in them respectively.
My db is on my local machine and I'm using Oracle 11g so I don't understand what the problem is. Any help would be appreciated.

So my problem was that i was connected to the SID orcl on sql developer
and my sql plus was connected to my SID that i named during the 11gs installation
ran this on sqlplus=
var OHM varchar2(100);
> EXEC dbms_system.get_env('ORACLE_HOME', :OHM);
> PRINT OHM // ---> ORACLE_HOME
to find my oracle 11gs home directory
there was a file called 'tnsnames.ora' it was located at [Your_ORACLE_HOME]/Network/Admin.
Opened it using Notepad( any text editor should work )
In tnsnames.ora file found the service name which i entered into sql developer and changed the port which was mentioned in the .ora file
works like a charm now.
Here is a link to a useful post that helped me achieve my conclusion
https://dba.stackexchange.com/questions/121251/sqldeveloper-ora-12505-tns-listener-does-not-currently-know-of-sid-given-in-co
credits to Do Long Bien

Related

How to add Database to default server in Postgres, if all databases are deleted?

I ran and new node application that used a Postgres SQL server. It created a default database called postgres and I wanted to remove it.
I used the below command and close the connection and was able to remove that database.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'postgres';
Now the pgAdmin looks like the below image.
I am not sure how to add a database again here. It always gives me errors while adding a new server that Database "postgres" does not exist. Any ideas or search query to google about this issue?
I am tempted to say that if you are randomly deleting system databases without first researching if they are needed, you deserve what you get. But while it is customary to leave the postgres database as default database for tools to connect to, it is certainly not forbidden to drop it.
The solution in your case is probably to reconfigure your pgAdmin connection to use template1 instead of postgres as "maintenance database". The only problem with that (and the main reason why the postgres database was introduced) is that it will prevent you from creating new databases with template1 as the (default) template if others are connected to that database as well.
You are connecting as user "postgres" and the default database name it will try is also "postgres". You should be able to specify a different database in the pgadmib settings though. Try "template0" and connect to that to create a new db.

How to create Oracle 19C Database SQL Developer New Connection?

Well I am a college student and I have a database project to build on Oracle 19c (SQL Developer) just like a management system. When I click on new connection in SQl Developer , then enter database name (my project name) and enter user name as system and pswd. and is SID I write 'orclpdb' and when I connect it gives an error that database is not open. How can I start making tables and stuff and complete my project on oracle 19c sql developer. Please guide me.
Update: While creating new database connection in SQL Developer, In Service name if I write 'orcl' and test then the connection is successful but when I write 'orclpdb' it says 'database not open'
So it sound like the container database (orcl) is started but the pluggable database (orclpdb) is not. You need to start it.
In order to actually manage a database you are going to have to learn to work without SQL Developer, and use the command-line utility sqlplus.
From a command line:
C:> set ORACLE_SID=orcl
C:> sqlplus / as sysdba
SQL> alter pluggable database orclpdb open;
In the above, the sqlplus command is launching the command line utility 'sqlplus'. the '/' indicates to make a local connection to the database specified by the env variable ORACLE_SID, using OS authentication (os user is a member of the ORACLE_DBA group), and connect with 'sysdba' authority. On the next line the 'SQL>' is just indicating you are now at the sql prompt within sqlplus, you actually enter the 'alter' command, whose purpose should be self-evident.
The listener is a totally separate process. It is like a telephone switchboard. It 'listens' (hence, its name) for connection requests coming across the network, and set up the connection, then is out of the picture. You check its status at the command line:
C:> lsnrctl status
One last bit of useful (for us) information. What this the connection 'type' you've defined in SQL Dev? Is it 'basic' or 'tns'? Either way, what did you specify for the values? Please name the field(s) AND the value you supplied.

Invalid Object Name in mssql 2005

We currently have an issue with our MSSQL 2005 database. We've recently undergone a migration from windows server 2003 to 2008. SQL Server has remained as 2005. I'm using SQL Server Management Studio to work on.
All the tables in the database follow the format: [SCHEMA].[TABLE_NAME]
When I enter the SQL:
SELECT * FROM [table_name]
I get the error message: Invalid object name '[table_name]'.
If I type in:
SELECT * FROM [schema].[table_name]
This works fine. The username we log into the database with owns the schema which is prepended to all the table names.
The problem is, we have 3rd party companies which have software which exports data from the database. 2 companies have now tried to run their exporters, however are getting the error 'Invalid object name'. The software is logging in with the username which owns the schema.
My question is exactly the same as this one I've found on the internet:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99802
However the answer on that question seems to be full of keywords rather than actual sentences which makes it very hard to understand.
If anyone could help, it'd be greatly appreciated.
Many thanks
Phil
Set the default schema for the 3rd party's username to the schema their un-prefixed references should point to:
ALTER USER foo WITH DEFAULT_SCHEMA = [bar];
(This is different from owning the schema.)
And tell them to write software correctly. In SQL Server you should always be specifying the schema name, even if you always use dbo.

Problem creating database using SQL Server Management Express

I am trying to create a database using SQL Server Management Express.
The following error occurs:
TITLE: Microsoft SQL Server Management
Studio Express
Create failed for Database
'dbTestDBase'.
(Microsoft.SqlServer.Express.Smo)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing
a Transact-SQL statement or batch.
(Microsoft.SqlServer.Express.ConnectionInfo)
CREATE DATABASE permission denied in
database 'master'. (Microsoft SQL
Server, Error: 262)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
Run Microsft SQL Server Studio as administrator....your problem will be solved
It's very clear: the credential you are using doesn't have enough privileges to be able to create a new database. Are you logged in using Integrated Windows Authentication or Sql Server Authentication? Make sure your credentials have the dbcreator role either way.
http://msdn.microsoft.com/en-us/library/ms176014%28v=SQL.90%29.aspx
If the computer is part of Domain. Log-in as local administrator account on the work station (maybe because the MSQSQL is installed on the computer using local administrator account, means that the local administrator account has systemadmin access on SMSQL), then when you are already logged as local administrator. open the MSSQL , now add/edit MSSQL security account.
I had this same problem. but solved!
you should go to your specify folder where database created (ex:C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA)
then right click on data folder -> properties-> advanced
then uncheck compress content to save disk space.
that's it.
Well, the error message seems to be pretty clear:
CREATE DATABASE permission denied in
database 'master'.
Obviously, the user account you're using doesn't have the permission to create a new database. Is that possible? What kind of user are you using?
Also: can you show us the CREATE DATABASE statement you're using??
Just check whether path is specified or not
For example : "C:..\MSSQL\DATA", in both the columns of Database files in the New Database wizard
I hope this solution will help someone!
My problem started when I had deleted the previous user from PC Management and from registry. Then I create a fresh-std user. and trying to create database from the new user, and that's where my problem started.
After searching for the better solution, I conclude by Uninstalling MS Server Express Database completely from my PC and re-install it again. This save time and solved my problem.
I hope this solution helps someone too!
I had similar issue and was solved by executing below command
--Step1 Find if it is used by some other PID
Use
master
GO
IF
EXISTS(SELECT request_session_id FROM
sys.dm_tran_locks
WHERE resource_database_id =
DB_ID('Model'))
PRINT
'Model Database being used by some other session'
ELSE
PRINT
'Model Database not used by other session'
-- Step 2 - Identify
SELECT request_session_id FROM
sys.dm_tran_locks
-- Step 3 Get PID
WHERE resource_database_id =
DB_ID('Model')
-- Step 4 Get the EventInfo
DBCC InputBuffer(214)
-- Step 5 Kill the PID
Kill 214
Hope this helps
I had the same problem when trying to create the database with Right Click + New Database on Databases.
The solve was using New Query and the command to create database:
CREATE DATABASE databasename;
In the end I want to mention that I was logged in Management Studio with (localdb)\v11.0 over windows authentication.

How to determine an Oracle query without access to source code?

We have a system with an Oracle backend to which we have access (though possibly not administrative access) and a front end to which we do not have the source code. The database is quite large and not easily understood - we have no documentation. I'm also not particularly knowledgable about Oracle in general.
One aspect of the front end queries the database for a particular set of data and displays it. We have a need to determine what query is being made so that we can replicate and automate it without the front end (e.g. by generating a csv file periodically).
What methods would you use to determine the SQL required to retrieve this set of data?
Currently I'm leaning towards the use of an EeePC, Wireshark and a hub (installing Wireshark on the client machines may not be possible), but I'm curious to hear any other ideas and whether anyone can think of any pitfalls with this particular approach.
Clearly there are many methods. The one that I find easiest is:
(1) Connect to the database as SYS or SYSTEM
(2) Query V$SESSION to identify the database session you are interested in.
Record the SID and SERIAL# values.
(3) Execute the following commands to activate tracing for the session:
exec sys.dbms_system.set_bool_param_in_session( *sid*, *serial#*, 'timed_statistics', true )
exec sys.dbms_system.set_int_param_in_session( *sid*, *serial#*, 'max_dump_file_size', 2000000000 )
exec sys.dbms_system.set_ev( *sid*, *serial#*, 10046, 5, '' )
(4) Perform some actions in the client app
(5) Either terminate the database session (e.g. by closing the client) or deactivate tracing ( exec sys.dbms_system.set_ev( sid, serial#, 10046, 0, '' ) )
(6) Locate the udump folder on the database server. There will be a trace file for the database session showing the statements executed and the bind values used in each execution.
This method does not require any access to the client machine, which could be a benefit. It does require access to the database server, which may be problematic if you're not the DBA and they don't let you onto the machine. Also, identifying the proper session to trace can be difficult if you have many clients or if the client application opens more than one session.
Start with querying Oracle system views like V$SQL, v$sqlarea and
v$sqltext.
Which version of Oracle? If it is 10+ and if you have administrative access (sysdba), then you can relatively easy find executed queries through Oracle enterprise manager.
For older versions, you'll need access to views that tuinstoel mentioned in his answer.
Same data you can get through TOAD for oracle which is quite capable piece of software, but expensive.
Wireshark is indeed a good idea, it has Oracle support and nicely displays the whole conversation.
A packet sniffer like Wireshark is especially interesting if you don't have admin' access to the database server but you have access to the network (for instance because there is port mirroring on the Ethernet switch).
I have used these instructions successfully several times:
http://www.orafaq.com/wiki/SQL_Trace#Tracing_a_SQL_session
"though possibly not administrative access". Someone should have administrative access, probably whoever is responsible for backups. At the very least, I expect you'd have a user with root/Administrator access to the machine on which the oracle database is running. Administrator should be able to login with a
"SQLPLUS / AS SYSDBA" syntax which will give full access (which can be quite dangerous). root could 'su' to the oracle user and do the same.
If you really can't get admin access then as an alternative to wireshark, if your front-end connects to the database through an Oracle client, look for the file sqlnet.ora. You can set trace_level_client, trace_file_client and trace_directory_client and get it to log the Oracle network traffic between the client and database server.
However it is possible that the client will call a stored procedure and retrieve the data as output parameters or a ref cursor, which means you may not see the query being executed through that mechanism. If so, you will need admin access to the db server, and trace as per Dave Costa's answer
A quick and dirty way to do this, if you can catch the SQL statement(s) in the act, is to run this in SQL*Plus:-
set verify off lines 140 head on pagesize 300
column sql_text format a65
column username format a12
column osuser format a15
break on username on sid on osuser
select S.USERNAME, s.sid, s.osuser,sql_text
from v$sqltext_with_newlines t,V$SESSION s
where t.address =s.sql_address
and t.hash_value = s.sql_hash_value
order by s.sid,t.piece
/
You need access those v$ views for this to work. Generally that means connecting as system.