User Defined Types
Installing the User Defined Types
The UDTs support the creation of data-types that can be used as pre-defined data-types.
To install the UDT for Teradata:
- Log in to the database server as the user with the required permissions.
- Navigate to the
/opt/protegrity/directory. - To install the UDT for Teradata, run the following command:
./PepTeradata_UDTSetup_Linux_x64_<DBP_version>.sh - Press ENTER.
The prompt to continue the installation appears.***************************************************** Welcome to the Database Protector Setup Wizard ***************************************************** This will install the teradata user defined types on your computer Do you want to continue? [yes or no] - To proceed, type
yes. - Press ENTER.
The script extracts the files and installs the data types in the default directory. The script also sets the permissions for the data types.
[/opt/protegrity]: Unpacking... To get started with UDTs, please run /opt/protegrity/databaseprotector/teradata generate_udt_scripts.sh. Teradata UDTs installed in /opt/protegrity/databaseprotector/teradata. Permission for /opt/protegrity/databaseprotector/teradata is successfully set.
Creating the User Defined Types
The Teradata Data Warehouse Protector automatically creates the To-SQL and From-SQL transform, the ordering, and the necessary casts for a distinct UDT once the CREATE TYPE statement is issued.
On the Data Warehouse Protector installation, the /databaseprotector/teradata/udt/ directory is created with the following files:
generate_udt_scripts.shis an executable file that generates UDT scriptspepteradataudt.plmis a library that contains protect and unprotect functions for UDT usage.
The generate_udt_scripts.sh script generates UDT scripts using the following command:
/opt/protegrity/databaseprotector/teradata/udt # ./generate_udt_scripts.sh --help
Protegrity Data Security Platform - Teradata UDT Scripts
Usage: generate_udt_scripts udtname dataelement scid dbtype
udtname : UDT Name
dataelement: Data Element
scid : Security Coordinate ID
dbtype : Database data type, must be one of: bigint,date,float,integer,varchar
The following are some limitations for the UDT arguments:
- Udtname – any applicable name
- Dataelement – DE deployed
- Scid – applicable security coordinate (0 by default)
- Dbtype – one of the data types bigint, date, float, integer, varchar.
Important: The scid parameter is no longer used and is retained for compatibility purpose only.
To create the User Defined Types:
Log in to the server as the user with the required permissions.
Navigate to the
/opt/protegrity/databaseprotector/teradata/udt/directory.To view the files and directories in the
../udt/directory, run the following command:/opt/protegrity/databaseprotector/udt # lsPress ENTER. The list of available content appears.
/opt/protegrity/databaseprotector/teradata/udt # ls generate_udt_scripts.sh pepteradataudt.plm sqlscriptsTo generate the UDT scripts required for creating the UDTs, run the following command:
./generate_udt_scripts.sh <udtname> <dataelement> <scid> <dbtype>For example:
./generate_udt_scripts.sh UDT_VARCHAR AES128 0 varcharPress ENTER. The script generates the following
.sqlqueries for the UDTs in the/opt/protegrity/databaseprotector/teradata/udtdirectory.create_UDT_VARCHAR.sql drop_UDT_VARCHAR.sqlNote: It is recommended to use the data element names in the upper-case.
Note: Modify the
.sqlqueries using thebtequtility for error handling.To start the
btequtility, run the following command:/opt/protegrity/databaseprotector/teradata/sqlscripts # bteqPress ENTER. The prompt to log in to the database appears.
Enter your logon or BTEQ command:To log in to the database, run the following command:
.logon <username>Press ENTER. The prompt to enter the database password appears.
Password:Enter the database password.
Press ENTER. The connection to the Teradata Data Warehouse is established successfully.
*** Logon successfully completed.To create the UDTs, run the following query:
.run file=create_UDT_VARCHAR.sqlPress ENTER. The query creates the UDTs and the following message for each of the created UDT appears.
*** Function has been created. *** Warning: 5607 Check output for possible warnings encountered in compiling and/or linking UDF/XSP/UDM/UDT. *** Total elapsed time was 1 second.Note: It is recommended to create only one UDT for each data type.
Creating an additional UDT, with a basic data type that is used by an existing UDT, results in a linked error.To grant the access permissions to the UDTs, execute the following SQL statements using the bteq utility.
To provide the
executeaccess to the UDTs, run the following command:chmod 755 create_UDT_VARCHAR.sqlPress ENTER.
To provide the
UDTUSAGEaccess for the UDTs to public with aGRANToption, run the following query:GRANT UDTUSAGE ON SYSUDTLIB TO PUBLIC WITH GRANT OPTION;Press ENTER.
To provide the
executefunction for all the UDTs to public with aGRANToption, run the following query:GRANT ALL ON TYPE SYSUDTLIB.UDT_VARCHAR TO PUBLIC WITH GRANT OPTION;The protect/unprotect operations for the UDTs must be executed using the
btequtility.Press ENTER. The script creates the UDTs and grants access permissions using the SQL statements.
Feedback
Was this page helpful?