SQL Developer Read Only Test Mode - oracle

I am using SQL Developer to construct a PL/SQL file for Oracle DB updates and I want to test them out, but I dont have UPDATE privileges. Is there some type of test mode that would pretend I do and save things locally? Or do I have to export the data I need into a local DB and test it there?

You'd need to have a database where you do have update privileges to run your test or some way in your environment to cause your script to be run (i.e. sending it to a DBA to run against a lower environment, checking it in to your build tool to have the build tool run the script against the lower environment, etc.). SQL Developer is just a client that connects to other databases, it doesn't include a database that you could run the script against.

Related

Oracle sql or pl/sql command for checking if remote database is available i.e. similar to OS command tnsping

In my PL/SQL script, I have requirement to test the connectivity of remote data. Normally, in OS shell, we use command tnsping. Is there any command in SQL or PL/SQL so that I can test connectivity.
Basically, I am getting some data using database link. I want my script to execute immediately. If remote database is available then I want to run query using database link. If remote database is unavailable then I want to skip the getting of data using database link. So, this is the reason why I am looking for.
Kindly guide me for proper way. So, that my script does not hang in case of unavailability of remote database.
I am using Oracle 12.1C.

Is it possible to execute a SQL script file stored on the database server using a remote command?

Say I have a SQL script physically stored on the database server. Is there a SQL command I can send Oracle from an application to tell it to execute that script?
(Yes, I know this sounds ridiculous. I'm considering it as part of a work around of a very nasty problem that "shouldn't happen" but does.)
The easiest option would generally be to use the dbms_scheduler package to run an external job. This would let you invoke a shell script that started SQL*Plus, connected to the database, and ran your .sql script.
It would also be possible to create a Java stored procedure that uses Java's ability to call out to the operating system to run the same shell script. That tends to be a bit more of a security issue, though, since you're ending up granting the owner of this procedure privileges to run any command on the database server as the oracle user. That would include things like connecting to the database as SYSDBA or corrupting the database (accidentally or intentionally) so it's something that auditors would generally frown upon.

Oracle Data Pump expdp to local computer that does not have oracle installed

Hi I've been reading this instruction:
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php#NetworkExportsImports
From my understanding, I need to login my local oracle database, establish a database link to the remote oracle server, then use expdp to export database to local.
But now I only have sqlplus installed in local computer, how can I expdp to local?
Thank you very much.
You can't. expdp only works locally. The database link is just a kludge to make the Oracle instance on your current machine be able to see the data in the other database. If you truly need a remote back up, your only non-custom or third party option would be exp, but that's deprecated. (I'm not aware of any third party solutions, either.)
Another option to consider is running the command on the remote server and then using something else to copy the file. This is more feasible if you run a Linux server, since you can likely use SSH and SFTP.
You could try Oracle Express on your local machine if you want to pursue the database link option. That is a very heavy solution, of course.
(In all honesty, I have had endless troubles with expdp anyway. Well, more with impdp, but still. The data dump/restore situation in Oracle is not very good, in my opinion.)

Run commandline command at remote Oracle server using SQL*Plus

I have a machine running Oracle 10g server in windows server 2008. I want to take backup of the database. I also want to take backup of some files saved on hard disk by oracle server that users have uploaded using my website.
I can connect to the Oracle server using sql developer and sqlplus. I can run sql queries on the server.
In order to take backup of database I have to run the command "exp" (this is the only way of taking backup of databases that I know). There might be some other way but there is another problem because of which I must run dos command. That problem is to take backup of files. These files are stored in c:\mydir. The folder mydir is not accessible anyway through web and is not a shared folder.
I have tried running "host " in sqlplus after connecting to oracle server, that is at "sql>" prompt. The command ran successfuly but at local machine, not at oracle server.
Edit: The "host" command is provided by sqlplus and is not an oracle command, means cannot be used in a query. Sqlplus even when connected to remote machine run the "host" command at local machine.
The target is to either make sqlplus run the "host" command at remote machine, Or run the dos command from inside a pl/sql query (independent of sqlplus).
In addition to what Justin has written:
If you want to take a logical snapshot of the database the new DataPump tool is preferred over the old (and deprecated) exp tool.
DataPump is a commandline tool (expdp) but also has a SQL API through Oracle packages and procedures.
The Data Pump API (including examples)
DBMS_DATAPUMP (reference)
But if you want a "real" backup you should look into RMAN
It is possible to create a Java stored procedure on the database server that executes an operating system command on the Oracle server. But it would be extremely unusual to use the export utility to backup a database-- that only creates a logical backup not a more appropriate physical backup. And it would be extremely unusual to run a backup by connecting to the database via SQL*Plus and spawning a job on the server operating system. It would make much more sense to create a job using the Windows scheduler on the database server that ran whatever export commands you want to run.

Database Project and SQLCMD doing a comparison

We currently have a Database Project, which we wrote a WIX Installer for to deploy it, using VSDBCMD means we are able to do a comparison against the current database, and do an update or fresh install when required.
However we have found some issues with this:
1. We need a separate Database installer that needs to be executed on the SQL server (if you want to do it from another server, we found can only be done if it is a domain server and u use a account that has access to both systems and is a sysadmin on the sql).
2. Compact framework has to be installed for VSDBCMD to work.
We are now at a point where we would like to integrate our Database installer into our main installer, this means that most of the time we will be installing from a different system then the sql machine and would like to be able to use an SA account to install the database.
We have tried out SQLCMD, but that doesn't seem to be able to do a comparison on an already existing database.
I would like to know that if a) it is possible to use SQLCMD to do a comparison and how that would work, or b) if SQLCMD is not an option, can VSDBCMD work with an sa account, rather then a domain account?
Thanks
SQLCmd can only execute SQL commands or batches on a database server - it assumes the person writing the script knows the current state of the database and the script will be executed as if it was run in SSMS.
If you want to use the declarative development powers of Visual Studio then you need to use VSDBCMD to deploy them onto your server machine. If you use a connection string in the command line that doesn't use integrated login, you should be able to execute it from your client machine. For example:
"Data Source=$Server;User ID=$UserName;Password=$Password"
Then a SQL Server login for $UserName would suffice.

Resources