<a id="teradata-development-setup"></a>

# Setting up the Teradata Development Environment

* Download [Teradata Express](https://downloads.teradata.com/download/database/teradata-express-for-vmware-player) for the version you would like to test against.
* Extract the archive file with [7zip](https://www.7-zip.org/)

If you have VMware Player or Workstation, you can import this virtual machine and use it immediately.

## Importing using VirtualBox

If you don’t have VMware Player or Workstation, or prefer to use VirtualBox, you can complete the following steps:

1. Open VirtualBox and create a new virtual machine.
2. Name the virtual machine, set the type to `Linux`, and version to `openSUSE (64-bit)`. Click “Continue”.
3. Set the virtual machine to a minimum of 4096MB of memory. Click “Continue”.
4. Select “Do not add a virtual hard disk”, and click “Create”.
5. A warning will pop up about creating a virtual machine without a hard disk. Click “Continue”.
6. Select your newly created virtual machine, and open “Settings”.
7. In the “Storage” tab, select the “Controller: IDE”, and add a hard disk.
8. For each of the three extracted disk files (with .vmdk file extension), do the following:
   1. A window will appear, asking if you want to select an existing disk. Click “Choose existing disk”.
   2. A new window will appear with a list of hard disks. Click “Add”.
   3. Navigate to the location where you extracted Teradata Express, and select any one of the three disks.
   4. Click “Open”. The disk file should now appear in the list of “Not Attached” disks.
   5. Select the disk that you just imported. Click “Choose”.
9. Once you’ve added all three virtual hard disks, choose the “Network” tab.
10. Open the Advanced settings, and click on “Port Forwarding”.
11. Add a new port forward for the database connection
    1. Click “Add Rule”, it should be an icon including a green plus.
    2. Name the rule “Teradata JDBC”
    3. The “Host Port” should be `1025`
    4. The “Guest Port” should be `1025`
12. Optionally, add a port forward for SSH access
    1. Click “Add Rule”.
    2. Name the rule “SSH”
    3. The “Host Port” should be `2222`
    4. The “Guest Port” should be `22`.

    #### NOTE
    You will be able to SSH into the running machine with `ssh root@localhost -p 2222` with password `root`.
13. Click **OK** to exit the port forwarding window, and then click **OK** to exit the settings window.
14. Click **Start** to start your virtual machine (usually takes 2-5 minutes). After your machine becomes operable through the terminal, the database initializes.

You can now proceed with the remainder of the quick start, with the database running in the background.

## Set Up Teradata Test Account

1. In your Teradata VM (or over SSH), start BTEQ and log in:
   ```none
   bteq

   .logon dbc

   dbc
   ```

   Your output should resemble:
   ```none
   BTEQ 16.20.00.04 Tue Nov  5 18:03:15 2019 PID: 10393

   +---------+---------+---------+---------+---------+---------+---------+----
   .logon dbc

   *** Logon successfully completed.
   *** Teradata Database Release is 16.20.32.01
   *** Teradata Database Version is 16.20.32.01
   *** Transaction Semantics are BTET.
   *** Session Character Set Name is 'ASCII'.

   *** Total elapsed time was 1 second.
   ```
2. In the BTEQ command prompt, create another user `dev` with password `dev` and give them access to their database `dev`.
   ```none
   CREATE USER dev AS PERM = 1000000000 BYTES PASSWORD = dev;
   GRANT ALL ON dev TO dev;
   ```

   Your output should resemble:
   ```none
   CREATE USER dev AS PERM = 10000000 BYTES PASSWORD = dev;

   *** User has been created.
   *** Total elapsed time was 1 second.

   GRANT ALL ON dev TO dev;

   *** Grant accepted.
   *** Total elapsed time was 1 second.
   ```
3. Quit BTEQ:
   ```none
   .quit
   ```

   Your output should resemble:
   ```none
   .quit
   *** You are now logged off from the DBC.
   *** Exiting BTEQ...
   *** RC (return code) = 0
   ```

## Shutting down the Teradata Development Environment

When it’s time to shut down, you should stop the database gracefully, and power-off the VM:

1. Open the VM window, or SSH into the machine. You will need a root prompt to shut off the system.
2. Stop the database
   ```none
   /etc/init.d/tpa stop
   ```

   Your output should resemble:
   ```none
   PDE stopped for TPA shutdown
   ```
3. Shut down the virtual machine
   ```none
   poweroff
   ```
