Backingup Database using SQL script

Hello,
Let me start by saying I am new to Oracle, and I am trying to learn how to do a project where I must write an SQL script that can be used to back-up all the database files (i.e. control, redo log, and data files).  Assuming that all of the files are stored in one folder, the source and destination locations of these files must be provided as "substitution variables".  The script must implement the following tasks (directions)
Connect as user SYS with SYSDBA role
Shutdown the database
Copy the database files from the source location and store in the destination location
Restart the database
Connect as user SCOTT
In addition the script must use the "HOST" command to issue the operating system command to perform the copy task.
*Since this is just a learning project, and not a real scenario, I cannot run my script in SQLplus to verify if it is correct. This is why I am asking for some professional advice. I am currently working with Oracle 11g Enterprise running on a client Windows XP OS.
Below is what I have determined is a cold backup, please let me know if what I am doing is correct so far, and if not can you please steer me in the right direction.
connect SYS/<password> as SYSDBA
shutdown;
HOST copy from &source_file to &destination_file;       --this is the line that is confusing me.
connect SYS/<password> as SYSDBA
startup;
connect scott/tiger
thank you in advance for your time and input.

Thank you Brian and Frank. I agree with you that RMAN is the best way to perform a backup (from what I have read over the last week or so) in a production scenario., especially if the DB needs 24/7 access. Also , thank you Brian for the helpful links.
I currently have the free Oracle Enterprise 11g edition downloaded to my computer, running on VB with client Windows XP OS. But being new at this I find myself scared of running bad script that may break down my DB. I know I can just reload it and start over, but I am trying to approach this as carefully as possible. Although, the error codes help me understand what I am doing wrong a lot of the time.
Also, thank you Frank for the shutdown immediate advice. I also like the idea of writing/saving data to the spool for future reference  that will definitely come in hand down the road. I didn't think about writing a .bat file to run via SQL*Plus, that would also be a great alternative.
Continuing with the hypothetical scenario that I need to perform a very basic cold backup that requires a shutdown (with archive logging off) and a restart, do you think this script would run error free. Also, assuming the substitute variables are actual paths to where the whole of the database files are stored and their new destination file actually exists.
--Windows XP OS
connect SYS/<password> as SYSDBA
shutdown IMMEDIATE;
HOST copy &source_file &destination_file
connect SYS/<password> as SYSDBA
startup;
connect scott/tiger
Thank you again for your time and patience.
I find myself learning more from asking questions to professionals on this site than from my own professors.

Similar Messages

  • Question about creating new tables using SQL script in WebLogic Server

    Hi,
    I am new to WebLogic and I am following a book Java EE Development with Eclipse published by PACKT Publishing to learn
    Java EE.  I have installed Oracle Enterprise Pack for Eclipse on the PC and I am able to log into the WebLogic Server Administration Console
    and set up a Data Source.  However the next step is to create tables for the database.  The book says that the tables can be created using
    SQL script run from the SQL command line.
    I cannot see any way of inputting SQL script into the WebLogic Server Admistration Console.  Aslo there is no SQL Command line in DOS.
    Thanks  for your help.
    Brian.

    Sounds like you are to run the scripts provided by a tutorial to create the tables, right?  In that case, you may need to install an Oracle client to connect to your database.  The client is automatically installed with the database, so if you have access to the server that hosts the database, you should be able to run SQLplus from there.
    As far as I know, there is no way to run a script from the Admin Console.  I could be wrong, however.

  • Write to ERP Tables on HANA DB using SQL script

    Hello All,
    We are using HANA as our primary database for ABAP system and trying to feed the data to ABAP tables using SQL script and experiencing authorization errors . Please see below for more details.
    Scenario.
    I am getting no authorised error when i try to write some data to Z* tables using SQL script in HANA studio.But I am able to create new tables in the same schema.
    As shown above Query1: SAPSR1 is the schema which contains underline ABAP tables. ZGSA is existing table and now i am trying to insert new rows into it.
    Query 2&3: Creating new tables in SAPSR1 works fine.
    Can you please suggest me whether it is right approach or i need to have RFC to update these table from some other tool/app?.
    Thanks in advance,
    Naresh

    Hi Naresh,
    Obi Wan would now probably say: "this is not the functionality you're looking for".
    Even though you are working with Z-tables you really don't want to start messing with those from outside the context of the NetWeaver system.
    Instead you want to keep the control over all tables in the NetWeaver schema completely  to the SAP<sid> user and NetWeaver.
    For your data loading scenario, just write a simple ABAP report with native sql or an AMDP to do the copying of the data for you.
    Don't spread your code across the landscape and don't loosen access restrictions on your schema.
    - Lars

  • Set maximum server memory by using sql scripts

    Dear all
    How to set maximum server memory by using sql scripts in sql server 2014? Thx a lot
    Best regards,
    Wallace

    You can use
    sys.Sp_Configure to set max server memory
    Here are some recommendation for Max Server memory based on RAM size
    GB
    MB
    Recommended Setting
    Command
    16
    16384
    14745
    EXEC sys.sp_configure 'max server memory (MB)', '14745'; RECONFIGURE;
    32
    32768
    29491
    EXEC sys.sp_configure 'max server memory (MB)', '29491'; RECONFIGURE;
    64
    65536
    58982
    EXEC sys.sp_configure 'max server memory (MB)', '58982'; RECONFIGURE;
    128
    131072
    117964
    EXEC sys.sp_configure 'max server memory (MB)', '117964'; RECONFIGURE;
    256
    262144
    235929
    EXEC sys.sp_configure 'max server memory (MB)', '235929'; RECONFIGURE;
    512
    524288
    471859
    EXEC sys.sp_configure 'max server memory (MB)', '471859'; RECONFIGURE;
    1024
    1048576
    943718
    EXEC sys.sp_configure 'max server memory (MB)', '943718'; RECONFIGURE;
    2048
    2097152
    1887436
    EXEC sys.sp_configure 'max server memory (MB)', '1887436'; RECONFIGURE;
    4096
    4194304
    3774873
    EXEC sys.sp_configure'max server memory (MB)', '3774873'; RECONFIGURE;
    Hope this will help
    Glad to help! Please remember to accept the answer if you found it helpful. It will be useful for future readers having same issue.

  • How to start or shut down database using sql developer in windows

    Dear Sir/Madam,
    how we start or shut down database using sql developer in windows
    we are using oracle 11g release2, unix, java & oracle oracle weblogic administration
    Thanks & Regards
    Manish Kumar
    Datbase Team
    TCS Ltd.

    HI, Welcome to OTN form,
    SHUTDOWN is not a SQL statement but a SQL*Plus command . You cannot use SHUTDOWN in PL/SQL.
    Check following link:
    http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve042.htm#i2699551
    More Information please check OTN discussion: https://forums.oracle.com/thread/2349159
    Thank you

  • How to delete database using sql

    I have to delete some databases from oracle 8i. I tried it using the Database Configuration Assistant and I get stuck indefinately as the message always says connecting but nothing happens.
    How can I delete databases using sql not thru the DCA?
    Thanks

    files related to the database and follow these steps:
    1.- shutdown the database
    2.- Delete all files ( Control Files, .dbf, Redo's, Archive�s, parameter file, password file )
    3.- Delete the entrance of this database from
    listener.ora and from tnsnames.ora files.
    and that's it.
    Joel P�rez

  • From SharePoint Content Database, Using SQL-Server Query how to fetch the 'Document GUID' based on 'Content Type'

    I want to get all the documents based on content type using SQL Server Query. I know that, querying the content database without using API is not advisable, but still i want to perform this action through SQL Server Query. Can someone assist ?

    You're right, it's not advisable, may result in corruption of your databases and might impact performance and stability. But assuming you're happy to do that then it is possible.
    Before you go down that route, have you considered using something more safe like PowerShell? I've seen a script exactly like the one you describe and it would take far less time to do it through PS than it would through SQL.

  • Cannot connect to database using SQL*Plus

    Hi, I have Oracle 10g XE installed in my labtop and I cannot connect using SQL*Plus.
    I can connect using the broser User Interface though, which I was able to do after doing the following procedure to change the password of the sys account:
    -     open a command prompt
    -     - type sqlplus
    -     On the “Enter user-name” line, type /as sysdba
    -     On the SQL> prompt, type alter user sys identified by NewPassword;
    But the thing is that even though I am able to connect using sys/NewPassword from my browser UI, I dont get the same result when doing it using the SQL prompt.
    What I am trying to do is this:
    SQL> connect sys/NewPassword
    Then I get first a warming saying that I need to use either sysdba or sysoper to connect to the system account, but neither of those work.
    Can anyone advice me on this matter?
    Thanks in advance

    Thanks for that.
    I run the command to list the usernames on the database and I got SYS and SYSTEM in the list. But again, when I try to use SYS with a password that I know is working because I can access it through the browser UI, it doesnt work. It seems like this sys is different to the sys I used in the UI.
    I dont know if I am explaining myself correclty... In the Browser UI I use sys, and a password and I get connected to the sys account. However, if I try to use the same sys.password combination from my sqlplus prompt, I get error messages
    Does this make sense at all?

  • Cannot connect to database using SQL Developer

    Ok. Here are the facts:
    1) I can connect to the database using PL/SQL Developer.
    2) I wanted to try SQL Developer and I am unable to connect to the same database with SQL Developer. I provide username and password and select "network alias" and click test and I get "Network adaptor could not be established"
    3) TNS names.ora file resides on a mapped drive which clearly is accessible by PL/SQL developer but not by SQL developer.
    What am i missing?
    Thanks a lot

    If you can select a network alias, then sqldeveloper has found your tnsnames and the problem lies elsewhere.
    Is the network drive specified by a UNC? SQLDeveloper doesn't work well with unc names.

  • How to repair database using SQL server 2008 and C#

    How to repair database in SQL server 2008 using C#
    Musakkhir Sayyed.

    Unfortunately your post is off topic as it's not specific to SQL Server Samples and Community Projects.  
    This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it.  The links I provide below will help you determine the right forum to ask your
    question in.
    For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
    Office, IE, and other products.
    For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
    search for your product name.
    For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
    search for your product or issue.
    If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
    If you think your issue is related to SQL Server Samples and Community Projects and I've flagged it as Off-topic, I apologise.  Please repost your question and include as much detail as possible about your problem so that someone can assist you further. 
    If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
    When you see answers and helpful posts, please click Vote As Helpful,
    Propose As Answer, and/or Mark As Answer
    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID:
    Microsoft Transcript

  • How to create database using shell script

    hai
    how to create database using shell script

    The documentation details the steps to create a database manually. Another option is to use DBCA to create the scripts. DBCA will give you a complete set of scripts that will create a database.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref220

  • Is this the right way to implement a database using SQL Server Express?

    Purchase a single central server (if you don’t have one already) and house it in the Wild Wood Apartments headquarters located in San Francisco, California
    Purchase and install Windows Server 2012 Datacenter onto this single central server.
    Along with the Windows Server 2012 Datacenter, you will have to purchase a license called Client Access License or commonly referred to as CAL
    Install SQL Server Express onto this single central server as well
    You will then need to install remote desktop access to each computer in the 20 building complexes Wild Wood Apartments owns. This allows each complex manager to access SQL Server Express on their computer and input information into the database.
    Is there anything that I would have to add on or include, am I missing something, or is something incorrect?
    Thank you

     This allows each complex manager to access SQL Server Express on their computer and input information into the database.
    Yes, but application software must be developed or purchased.
    Your design would work for a small scale database and application. More likely you need a pay SS product such as Standard Edition.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • How to backup database using sql query?

    Hello,i'm student, i'm researching oracle database,i want to backup database that using sql query (like backup query in SQL SERVER) ,how to do that ??
    Thank!

    No, database backups cannot be done from within the database.
    Commands for backups are outside of the database.
    See the "2 Day DBA Guide" http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/toc.htm
    and the "Backup and Recovery Users's (actually Adminsitrator's) Guide : http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/toc.htm
    Hemant K Chitale

  • How to upgrade the schema on both the sites using sql scripts?

    Hi Experts,
    I need some help.
    I have two sites SITE A and SITEB, on both the sites GG is installed and running (DML Bi- directional replication). I have schema SCHEMA1 on both the sites which are configured for replication and replication is working from last one year.
    Now I wanted to upgrade the SCHEMA1 on both the sites. There are three .sql script which has many SQL commands like create table, create sequence, create procedure, insert record etc. I wanted to run that SQL file one both the sites.
    So should I stop all the process on both the sites SITEA and SITE B (including manager process) ,execute the SQL scripts on both the sites and then start the process again ? Will it work?
    Is there any other best way to do this?
    Could you please suggest the steps so that I can successfully execute theses scripts on both the site to upgrade the schema1.

    There is no blanket answer here; it depends. Main questions are:
    1. Do the SQL scripts update existing tables?
    2. Are you replicating DDL in one direction? (DDL should only be replicated one way even when doing bi-directional, do DDL should only be issued on the node capturing DDL
    3. Are you using a wildcard (*) from table names or using an explicit list?
    Easiest thing is if you're replicating DDL from A to B and apply DDL to A only. This assumes that the application writing to these tables can handle DDL changes under the covers. If these are new tables supporting new application features then you would simply enable said features after apply sql files.
    From there it gets more complicated and would need answers to the above questions before going down each line of logic. But try to remember what's really going on here. Data in one form (DDL) is being captured and send along. If the "shape" (DDL) of that data changes then the extract and replicat need to update their meta data to handle it correctly. If change data encounters a different shape than what's cached then you will become out of sync.
    I'm not sure if that makes sense but again, the answers to the questions above will be indicate where more detailed explanations should be focused. In short, we need more detail about what those scripts do and your current setup.
    Good luck,
    -joe

  • Open Window Media Player Database using Sql Server?

    I have a copy of Windows Media Player database that nolonger relates to actual files.
    I would like to be able to list the file paths stored in that database.
    I don't suppose that I could use SQL Server to do that, could I?
    Is there any other way at all to make such a list?
    Even a suggestion to try something would be appreciated.
    Thanks in advance for any help at all.

    Hello,
    Please try to post your question on the following forum:
    http://answers.microsoft.com/en-us/windows/forum/pictures?tab=Threads
    You may get a faster response in that forum, since it is more relevant to the subject.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

Maybe you are looking for

  • Problem in  Creating a view using infotypes PA0001,PA0002,...

    Hi, Can anybody please help me how to create a Maintainence view using PA0001,PA0002,PA0003,PA0006,PA0032. I tried to create it using se54. when i use PA0003 as check table, i am not able to create relations with PA0001,PA0002,PA0032,PA0006. Thanks i

  • BAD Command Argument Error. 11 writing to Exchange 2007 - Help Please...

    Hi, I am writing an IMAP to IMAP mailbox converter. I am testing a UW mailbox that I have approx. 1200 messages in to a MS Exchange 2007 Server. I am performing a javax.mail.Folder destFolder.appendMessages(sourceFolder.getMessages()). I transfer alm

  • Calling a second frame from within an application

    I have a main class that sets up a frame for a frame class. However, from that frame, there is a button from which I would like to open another frame for data entry. I have a second frame class built. I have an empty ActionEvent method written for th

  • Deactivate the link between qualification and appraisal

    Hi expert, i have a question for the qualification(infotype 0024) and appraisal (infotype 0025) in PA here. After I maintained qualification for infotype 0024, i found that, when i go into appraisal(0025), the screen automaticlly switched to qualific

  • Macbook Air weird audio problem?

    Hello all, This is about an issue I have with my speakers, I realize there are alot of similar questions out there, but I have yet to find a solution, and since none of the cases I have read completely matched my situation I thought I might as well m