How to create a dump of a table


Template level External Article ID

KBA00020965

Issue

The dbdump utility allows you to quickly create a text file that contains the records of a specified database table.

Environment

FLEX

Resolution

Usage and Flags 

Here is how the usage for the dbdump command:
dbdump [-sqrcC] [-iN] [-k<key>] [-e<key>] [-l<len>] [-x[N][:Id]] [-m] [table_name [...] ]

FlagDescription
-s
Silent; don't display count of records dumped.
-qDo not include header
-rDump records in reverse order.
-cPerform basic check on field content (includes $check description), and only output records that fail the basic check.
-iN Use Nth index or named index for each table dumped
-k<key>Specify starting index key value, '+' separates fields
-e<key> 
Specify ending key value. '+' separates fields.
-l<len> 
Specify length of key that identifies a group.
-xN:Id 
Records dumped in XML format indented N tab level using 'Id' interface tagnames.
 -m 
 dump fields: modwhen, addwhen, modby, addby and securid in XML

Process for a basic dbdump of a table

WINDOWS

You must be logged on to the Windows Server in order to run sh and shell out properly.

  • From the Flex command line, type sh and hit ENTER
    • You will be presented with a Windows command prompt
    • Make note of the directory you are working from (It should be your home directory)
  • At the prompt, type dbdump and hit ENTER
  • Type the name of the table you want to output to .txt
  • Once finished, hit ENTER once more to simply return to the command prompt
  • Type start . to open the directory where the .txt file was written to

The below example walks through a dump of tblaw to the sds home directory:

Linux
Based on your Patch, the command for sh will behave slightly different. See below:

2018.3 and above

  • Typing sh from the Flex command line will open a PuTTy session which prompts for OS credentials. Keep in mind that this will likely not match what you use to login to Flex due to OS Separation and the management of application users in the syusradm table
  • Once authenticated, you will need to set the Flex environment so that you can run certain commands (including dbdump). To do this, type:

    # spillman -s bash
  • After hitting ENTER you will be prompted to verify the Terminal type. Just hit ENTER again and it will be correctly set
  • Verify which directory you are in by typing pwd and hitting ENTER (the default should be your home directory)
  • You are now in the proper environment to run the commands noted below

 2018.2 and below

  • Typing sh from the Flex command line will open a terminal emulator. From here, the Flex environment is automatically set and you can run various system commands including 'dbdump' as shown below

Commands

  • At the prompt, type dbdump and hit ENTER
  • Type the name of the table you want to output to .txt
  • Once it's finished, hit ENTER again to return to a command prompt
  • Type ls -ltr to list all contents of your working directory. You should see the table .txt file at the bottom.
  • You can now follow your normal process to transfer this file off the server (FTP, Filezilla, etc).