Split database file into multi files on different drives.

Hi,
I Have a large database file .mdf that eating my drive disk space. So i have installed another disk. Now I have 2 drives (other than OS drive) one has the .mdf file and almost full and the new drive which is empty.
I need to know How to split the .mdf into another file located on the new drive and keeping the original .mdf file not growing anymore ?

I know how to split an access file, but never done this with MDF, so if you know what connection string, then you should be able to change this code. However this will ask the user for location of file to be split, it will split in same folder then you can
move the splits to another folder.
This will allow you to choose how many records you want to split by, You can ignore the watchfolder part, or you can use that to automatically copy the split files, then add a delete from orginal source.
Anyway here is the code and I hope it can help with MDF files.
Imports Microsoft.VisualBasic, System, System.Diagnostics, System.IO, System.Windows.Forms
Imports System.Data.OleDb, System.Data, System.Data.SqlClient, System.Data.Odbc, System.Threading
Imports Microsoft.Office.Interop, System.Runtime.InteropServices, Microsoft.Office.Interop.Outlook
Public Class Form1
Dim sConStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
Dim aConStr, CurPr, WFolder, VFolder, SFolder, ZFolder, eFile, tFile, FileName As String
Dim TableName, aConStr2, II, IV As String
Dim Recs, Maxd, i, StartRec, EndRec, TRec, iii As Integer
Dim Parts As Decimal
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Split_Recs.Click
WFolder = txtBxPath.Text + "\"
FileName = txtBxAccess.Text
TableName = txtBxTable.Text
aConStr = WFolder + FileName
Recs = txtBxTotRecs.Text
Maxd = txtBxMax.Text
Parts = Recs / Maxd
i = 0
StartRec = i
EndRec = Maxd
Do While i < Parts
Dim FirstRec As String = StartRec + 1
Dim LastRec As String = EndRec
Dim TotRec As String = EndRec
TRec = EndRec - StartRec
TotRec = TRec
II = i + 1
IO.File.Copy("\\pw_prod\Watch_Input\Glenn-PTZ\db1.mdb", WFolder + txtBxJobNum.Text + "Pt_" + II + ".mdb")
TextBox3.AppendText(" Between " + FirstRec + " and " + LastRec + vbCrLf)
txtBxProgress.AppendText("Part: " + II + " Start " + FirstRec + " End " + LastRec + " Total: " + TotRec + vbCrLf)
TextBox5.Text = " Between " + FirstRec + " and " + LastRec
StartRec = StartRec + Maxd
EndRec = EndRec + Maxd
'Creates Queries in Main File
Dim con As OleDbConnection = New OleDbConnection(sConStr + aConStr)
Dim cmd As OleDbCommand = New OleDbCommand("CREATE PROC Variable" + II + " AS SELECT * FROM " + TableName + " where " + txtBxSort.Text + TextBox5.Text + " Order by " + txtBxSort.Text, con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
'Export each new query as new access file
Dim DevComm1Conn_1 As New System.Data.OleDb.OleDbConnection(sConStr + WFolder + txtBxJobNum.Text + "Pt_" + II + ".mdb")
DevComm1Conn_1.Open()
Dim DevComm1 As New System.Data.OleDb.OleDbCommand( _
"SELECT * INTO [Variable" + II + "] FROM [MS Access;DATABASE=" + WFolder + FileName + ";].Variable" + II, DevComm1Conn_1)
DevComm1.ExecuteNonQuery()
DevComm1Conn_1.Close()
i = i + 1
IV = i - 1
If IV = 0 Then
IV = 1
End If
If EndRec > Recs Then
EndRec = Recs
End If
TextBox5.Text = String.Empty
If txtBxWatchCopy.Text = "Yes" Then
IO.File.Copy(WFolder + txtBxJobNum.Text + "Pt_" + II + ".mdb", txtBxWatch.Text + "\" + txtBxJobNum.Text + "Pt_" + II + ".mdb")
End If
Do While IO.File.Exists(txtBxWatch.Text + "\" + txtBxJobNum.Text + "Pt_" + II + ".mdb")
Threading.Thread.Sleep(50)
Loop
Loop
txtBxProgress.AppendText("Total Parts: " + II + vbCrLf)
MsgBox("Match all counts to ticket. If not match talk to CSR")
End Sub
End Class

Similar Messages

  • Add a DB2 database file in different drive

    Dear all,
    I would like to add a DB2 database file in different drive which is added recently.
    eg: existing DB folders in drive H, now we need to add new data folder from drive J
    please help me on this step by step procedure, looking for the earliest reply
    regards
    sathish
    65 96724662

    Hi,
    what you have to do is to extend your tablespace with new containers on the new drive and AVOID REBALANCING !!!
    Do do that, you can either use the "alter tablespace" command with the "begin new stripe set" clause, or use
    the DBACOCKPIT to extend your tablespace and specify
    a new stripe set there.
    For details on the "alter tablespace" command see:
    http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.doc/welcome.htm
    and search for "alter tablespace"
    kind regards
    Thomas

  • Accessing the same database file using different handles/cursors

    Will there be any problems accessing the same database file using different DB handles in a transactional environment? We have implemented a process which have multiple transient threads coming up and initiating DB opens and read/write operations to the same database file using different handles and cursors?
    Can this potentially create any problems/bottlenecks? Can someone suggest the best way to deal with this scenario?
    Thanks in advance.
    SB

    Hi,
    Berkeley DB is well suited to the scenario you describe. You need to ensure that Berkeley DB is configured correctly for transactional access, the best information describing the requirements is in the Reference guide here:
    http://download.oracle.com/docs/cd/E17076_02/html/programmer_reference/transapp.html
    If there will be multiple threads operating concurrently, then you will need to design your application to detect and deal with deadlock situations.
    Regards,
    Alex Gorrod
    Oracle Berkeley DB

  • Windows Mail File on Different Drive

    Hello
    Is there a way to have windows 8.1 mail file on a different drive?
    Thanks

    Hi,
    Did you mean Windows 8.1 mail APP in start menu, isn't it? If so, I doubt there is no way to save these mail file on other location.
    Roger Lu
    TechNet Community Support

  • Standby database not configure while keep database files in different place

    Dear Friends ,
    I have to successfully configured "PHYSICAL STANDBY DATABASE" within the TWO databases ("PRIM" and "STAN" Database) when I kept datafile, controlfile and redolog files in the same location (like, "/u01/app/oracle/oradata/prim" location .
    In this successful configuration , I have to add the below two lines into the initprim.ora and initstan.ora both server respectively ...
    initprim.ora:
    ========
    DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/stan','/u01/app/oracle/oradata/prim'
    LOG_FILE_NAME_CONVERT='/u01/app/oracle/flash_recovery_area/stan','/u01/app/oracle/flash_recovery_area/prim'
    initstan.ora:
    ========
    DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/prim','/u01/app/oracle/oradata/stan'
    LOG_FILE_NAME_CONVERT='/u01/app/oracle/flash_recovery_area/prim','/u01/app/oracle/flash_recovery_area/stan'Now , in second scenario , I have to change Primary database server's datafile, controlfile and redolog file in the below folder :
    controlfile --> "/u01/app/oracle/oradata/prim/ctrlfile"
    redologfile --> "/u01/app/oracle/oradata/prim/redofile"
    datafile --> "/u01/app/oracle/oradata/prim/datafile"
    Similarly I have to create same folder in my STAN database server accordingly . and also add the above lines in same way :
    initprim.ora:
    ========
    DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/stan','/u01/app/oracle/oradata/prim'
    LOG_FILE_NAME_CONVERT='/u01/app/oracle/flash_recovery_area/stan','/u01/app/oracle/flash_recovery_area/prim'
    initstan.ora:
    ========
    DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/prim','/u01/app/oracle/oradata/stan'
    LOG_FILE_NAME_CONVERT='/u01/app/oracle/flash_recovery_area/prim','/u01/app/oracle/flash_recovery_area/stan'Keeping the above situation when I run the below command in STAN database server :
    [oracle@test ~]$ sqlplus /nolog
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 15 23:15:43 2010
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    SQL> conn / as sysdba
    Connected to an idle instance.
    SQL> startup mount
    ORACLE instance started.
    Total System Global Area 599785472 bytes
    Fixed Size 1220772 bytes
    Variable Size 163581788 bytes
    Database Buffers 427819008 bytes
    Redo Buffers 7163904 bytes
    Database mounted.
    SQL> alter database recover managed standby database disconnect from session;
    Database altered.
    The Command execute successfully but in the alert log of the STAN database server ,I get the below error :
    Completed: alter database recover managed standby database disconnect from session
    Mon Nov 15 22:46:52 2010
    Clearing online redo logfile 1 complete
    Mon Nov 15 22:46:52 2010
    Errors in file /u01/app/oracle/admin/stan/bdump/stan_mrp0_3695.trc:
    ORA-00313: open failed for members of log group 2 of thread 1
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prim/redofile/redo02.log'
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3
    Mon Nov 15 22:46:52 2010
    Errors in file /u01/app/oracle/admin/stan/bdump/stan_mrp0_3695.trc:
    ORA-00313: open failed for members of log group 2 of thread 1
    ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prim/redofile/redo02.log'
    ORA-27037: unable to obtain file status
    Linux Error: 2: No such file or directory
    Additional information: 3But I already created the above mention folder "'/u01/app/oracle/oradata/prim/redofile" successfully and the redo log files are also created there successfully , but I cannot understand why this error is showed ? And also no archivelogs are shifted from PRIM database server to STAN database server .
    Would u plz suggest me , why I cannot configure Physical Standby Database when I keep my database fles in the separate location ?
    help me plz ... ...

    Hi,
    I'm missing the steps you took renaming/moving the files on the primary.
    Since the location of datafiles is stored in the control file the controlfile of the standby might not know the new location yet.
    I suggest you read this http://www.cs.bris.ac.uk/maintain/OracleDocs/server.816/a76995/standby.htm#23603 and see if that helps
    Success,
    FJFranken

  • Will changing location for Itunes Apps and Music files to different drive (from dive C: to drive E:)now effect how they work. And will Itunes be able to find them, when I do a sync?

    Will changing the location of folders effect how my Itunes will run? As I am runnig out of room fast on my C drive. And have almost a 1 terrabyte of room on the drive I want it to all to go to. I was thinking of just cutting and pasting.

    WpgGizmo wrote:
    Will changing the location of folders effect how my Itunes will run
    No, but do not simply move files around else you will have a lot of grief...
    Do NOT move files then change iTunes prefs to a new location as this will not work.
    Quit iTunes.
    Copy your entire /Music/iTunes/ folder (and everything inside it) on your C: drive to the E: drive.
    Hold Shift and launch iTunes.
    Select Choose library and select the iTunes folder you copied to the E: drive.
    That is all you need to do. You do not need to change any other settings.

  • Preserve Aliases when move files to different drive

    I have several folders and files that I want to move from my laptop's internal hard drive to an external hard drive. I also have several aliases for these files that I want to KEEP on the internal drive. Is there any way to MOVE the folders and files to the external hard drive while preserving the aliases, so that when I click on the laptop aliases they will open the external hard drive files? I already found a discussion that shows how to MOVE files to the external drive as apposed to copying, but when I did it (using command drag), the alias residing on my laptop no longer worked.

    Hi,
    These scripts work, if the filename contains always three
    words separated by a space, otherwise the file will not be moved.
    The script will overwrite files that already exists in the destination folder.
    Here's the script that uses a shell
    set theFolder to "" -- drag/drop your folder between quotes
    set destination to "" -- drag/drop the folder "folder importen letters" between quotes
    do shell script "dest=" & (quoted form of destination) & "
    /usr/bin/find " & (quoted form of theFolder) & " -type f -maxdepth 1 \! -name '.*' -print0 | while read -d $'\0' f; do
    name=${f##*/}; folderName=${name%% *}; year=${name##* };
    if [[ "$year" = . ]]; then year=${year%%.*};fi
    if [ -d "$dest/$folderName/$year" ];then
    /bin/mv -f "$f" "$dest/$folderName/$year/$name"
    fi
    done"
    or this script if you prefer the Finder
    set theFolder to (POSIX file "") as string -- drag/drop your folder between quotes
    set destination to (POSIX file "") as alias -- drag/drop the folder "folder importen letters" between quotes
    tell application "Finder"
    repeat with tFile in (get files in folder theFolder)
    set {folderName, t_year} to my getTheseNames(name of tFile)
    if t_year is not "" then try
    move tFile to folder t_year of folder folderName of destination with replacing
    delete tFile -- because the command move, doesn't move on other volume, it duplicate
    end try
    end repeat
    end tell
    on getTheseNames(tname)
    set oldTID to text item delimiters
    set text item delimiters to " "
    try
    tell tname to set {t_base, t_end} to {text item 1, text item 3}
    set text item delimiters to "."
    set t_end to text item 1 of t_end -- text before the period = the year
    on error
    return {"", ""}
    end try
    set text item delimiters to oldTID
    return {t_base, t_end}
    end getTheseNames

  • Finding files on different drives when the drive names were changed

    So I had music located on two different external HD's, and when I plugged in my iPod, it changed the names of my drives. For example, I had music on drive "H" and drive "I", then when I plugged in my iPod it changed those drive names to "J" and "K". It is easy to change my folder location in iTunes, but that will only fix half of my music (I have over 45,000 songs in my library). How can I have iTunes find all those other songs that now have the exclamation point as the songs are spread out now throughout my iTunes library.
    I can not go along to each song or album and go through the process to find the location, that will take me FOREVER.
    Thanks for your help

    Connect the external drives & the iPod. Close iTunes. Open Control Panel > Administrative Tools > Computer Management > Disk Management. Reassign the drive letters used by each device until they match your original set-up. Start iTunes and, if you've got it right, all your tracks will be acessible.
    tt2

  • Move Lync 2010 database in different drive in same sql instance

    Hi,
    I am using Lync 2010 enterprise version and Lync database in SQL cluster.
    I have to move lync 2010 database files in different drive due to some space issue in the drive.
    Thanks

    Hi Deepak Srivastava,
    As far as I know, I recommend that you move databases by using the ALTER DATABASE planned relocation procedure .
    In simple terms, the steps are following:
    1. Backup the Database.
    2. Stop the services on Lync Servers.
    3. Move the database, and you could refer to this article:
    Move System Databases
    http://msdn.microsoft.com/en-us/library/ms345408.aspx
    4. Start the services on Lync Servers.
    5. Test the Lync feature.
    Hope it can be helpful.
    Best regards,
    Eric

  • How to move temp file, redo log to different drive oracle 9i

    Hi ,
    I am using oracle 9i
    by mistakenly, i have instaled oracle installable on system drive i mean c: drive.I have installed teh database on D: drive.
    For tunning perfomance i would like to move the redlog files and temp files to different drive.
    Could you please explain me the step by step procedure how to do this
    Thanks
    AITS

    Very easy -
    Create a new temp tablespace with the files on the drive you want, make it the default temp tablespace for any users/schemas you have created, then drop the old temp tablespace including datafiles.
    For the redo logs, create new groups, again with the logfiles on the dirves you want them on, cycle out of the old ones with "alter system switch logfile;" then drop them.

  • Transfer Datafile on Different Drive due to Disk Full

    I am using ORA 10G in WIndows 2003 Server. I got disk full on one drive. the drive contains ATBS tablespace with 30 datafiles. I am planning to transfer some (lets say 10 data files) to different drive. Please advise on how can I do this without data loss.

    Hi,
    You need to follow the steps
    1. Shutdown the database( Clean shutdown)
    2. Copy all the files to the new location
    3. Start the database in mount stage.
    4. Change the location of the files using Rename command to update the control file with new location
    SQL> shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount
    ORACLE instance started.
    Total System Global Area  432013312 bytes
    Fixed Size                  1249392 bytes
    Variable Size              83890064 bytes
    Database Buffers          339738624 bytes
    Redo Buffers                7135232 bytes
    Database mounted.
    SQL> select name from v$datafile;
    NAME
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\PROD01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST01.DBF
    *E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST02.DBF*
    7 rows selected.
    SQL> alter database rename file 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST02.DBF' to 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST02.DBF';
    Database altered.
    SQL> select name from v$datafile;
    NAME
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\PROD01.DBF
    E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEST01.DBF
    *E:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST02.DBF*
    7 rows selected.
    SQL>Last step is to open the database using alter database open; You can also rename the files by taking the tablespace offline. In that case your database needs to be archive log mode.
    Yes if you take your tablespace offline, users will not be able to access the objects in that tablespace or will not able to do use that tablespace.
    Regards

  • Database files into a single disk or multiple disk ?

    Hi All,
    I want to install oracle database 11gR2 in to database server. This database server has three internal disk so I plan to put DBF,redo and ctl file in to different disk..
    but this is the optimal configuration by putting all the Database files (DBF,redo and ctl) into a differnt differnt disk or put all the files into a single disk with differnt partition? I want to minimize the disk I/O.
    Thanks in advance.

    Hi;
    It depends what you expect from your system. You can put into a differnt differnt disk or put all the files into a single disk with differnt partition. If you put all in one partition its more managable, but It also bad for HA.
    You need to check your priorty and you need to decide what you have to do
    Regard
    Helios

  • Need to split the output into files

    Hi,
    I have a query regarding splitting the output into different files. Please help to resolve that.
    I have have select query query...
    SELECT INDEX_NAME FROM DBA_INDEXES WHERE TABLE_NAME=<Table Name>;
    If it returns less than 4 indexes then we have create one table and have to move those into the files.
    For example...
    File_1.sql
    ====
    index1
    index2
    index3
    If select statement returns more than 4 indexes then we have create 4 files and have to splict those indexes and has to move to those 4 files.
    For example....
    If select statement returns 13 records then...
    File_1.sql File_2.sql File_3.sql File_4.sql
    ===== ====== ======= =======
    index1 index4 index7 index10
    index2 index5 index8 index11
    index3 index6 index9 index12
    index13
    Index no need to be in order in any file and any file can I extra index in it.
    Can be ok if we have any procedure or shell script. Please help me on this?
    We are using 10.2.0.1 oracle db. Please let me know if you need any thing else?
    Thanks
    Pathan

    Are you trying to put the output from SQL reports in different files?
    Some reporting tools can do this.
    You have a couple of options to do this.
    Some reporting tools support the functinality to write to different files.
    Another way is to write a PL/SQL procedure using UTL_FILE, which can open multiple files based on your conditions and to write to them as you need to.
    An older, less elegant solution is to write nested SQL*PLUS scripts spooling to different files with the queries you need. A top level script would invoke the others, something like (untested)
    --in first script
    @subscript1
    @subscript2
    --in subscript1.sql
    spool whatever.lst
    select *
       from dual;
    ...

  • Split delimited file into multiple structures

    Hi experts,
    I have a delimited text file that has multiple row types - each row contains only one structure, but there could be 10 different row types (structures) in the file. I can figure out which structure each row belongs. Just need to come up with a way to dynamically split each line.
    I am trying to stay away from:
    case 'row type'
      when 'structure A'
        split into A1, A2, A3...
      when 'structure B'
        split into B1, B2, B3...
    end with.
    Rather, create a routine accepting file line and structure (or structure name) that returns the structure with data populated.
    Any suggestions?
    Thanks,
    Hyun Kang

    This may give you some ideas. 
    report zrich_0001.
    data: begin of itab1 occurs 0,
          fld1(10) type c,
          end of itab1.
    data: begin of itab2 occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          end of itab2.
    data: begin of itab3 occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          fld3(10) type c,
          end of itab3.
    data: tab_name type string.
    data: istr type table of string with header line.
    data: isplit type table of string with header line.
    field-symbols: <dyn_tab> type table,
                   <dyn_wa>,
                   <fs>.
    start-of-selection.
      call function 'GUI_UPLOAD'
           exporting
                filename = 'C:test.txt'
           tables
                data_tab = istr.
      loop at istr.
        split istr at ',' into table isplit.
        read table isplit index 1.
        concatenate isplit '[]' into tab_name.
        assign (tab_name) to <dyn_tab>.
        assign (isplit) to <dyn_wa>.
        delete isplit index 1.
        loop at isplit.
          assign component sy-tabix of structure <dyn_wa> to <fs>.
          if sy-subrc <> 0.
            exit.
          endif.
          <fs> = isplit.
        endloop.
        append <dyn_wa> to <dyn_tab>.
      endloop.
      loop at itab1.
        write:/ itab1-fld1.
      endloop.
      loop at itab2.
        write:/ itab2-fld1, itab2-fld2.
      endloop.
      loop at itab3.
        write:/ itab3-fld1, itab3-fld2, itab3-fld3.
      endloop.
    My file looks like this.
    ITAB1,Value1
    ITAB1,Value2
    ITAB2,ValueA,ValueB,
    ITAB2,ValueC,ValueD,
    ITAB3,ValueR,ValueS,ValueT
    ITAB3,ValueU,ValueV,ValueW
    You can see in this program, that the first column drives what internal table the data is written to for that line.
    Regards,
    RIch Heilman

  • Help needed with SQL to split huge data into two excel or text files.

    Hi,
    I have a table which has around 1850000 records. I want to split the data into two sets and import the data in .txt or execl file.
    How can i break upthe records using rownum or any thing
    select * from tablename where rownum<940000 fetched some records
    but
    when i gave select * from tablename where rownum>940000 it was not fetching records.
    Guideme

    when i gave select * from tablename where rownum>940000 it was not fetching records.try this
    select * from (select tablename.*, rownum rn from tablename) where rn >940000

Maybe you are looking for