Specifies the operating system path to the source data file (or any media that can be treated as a file).
As a best practice, the external table locations should not be within the /nz directory or its subdirectories because the data object files might accidentally interfere with IBM® Netezza® operations, and they might consume disk space that is needed for the operation of the Netezza database and software.
Starting in Release 7.1.0.1, the admin user can specify and manage the locations on the IBM Netezza host where users can store the external table data object files. Users who have the Manage System privilege can also manage the locations for the external table object files.
You use the SHOW EXTERNAL TABLE LOCATION command to display the current table locations. By default, data objects can be created in any of the paths on the Netezza host that are accessible by the nz user account.
TESTDB.ADMIN(ADMIN)=> SHOW EXTERNAL TABLE LOCATION;
ALLOWDIRECTORY
----------------
*
(1 row)
The asterisk indicates that there are no restrictions on the locations for the external table object files.
To restrict the locations for the external table data objects, the admin user or any privileged database user can add and remove table locations using the following steps.
TESTDB.ADMIN(ADMIN)=> REMOVE EXTERNAL TABLE LOCATION '*';
REMOVE EXTERNAL TABLE LOCATION
TESTDB.ADMIN(ADMIN)=> ADD EXTERNAL TABLE LOCATION '/export/home/nz/ext_tbl';
ADD EXTERNAL TABLE LOCATION
TESTDB.ADMIN(ADMIN)=> ADD EXTERNAL TABLE LOCATION '/tmp/ext_tbl';
ADD EXTERNAL TABLE LOCATION
The locations and the object file must exist on the system and be accessible by the nz user account before you can insert to or read from the external table.
After you specify the external table locations, you can use the SHOW EXTERNAL TABLE LOCATION command to review the list of supported table locations. After you restrict the external table locations, the restrictions apply when you create new external tables. Any existing external tables continue to use their specified data object locations.
When a user creates an external table and specifies a data object path that is not part of the allowed location list, the command fails with an error:
TESTDB.ADMIN(ADMIN)=> CREATE EXTERNAL TABLE my_ext_tbl SAMEAS tbl_retail
USING (DATAOBJECT ('/mydir'));
ERROR: Invalid path specified in DATAOBJECT, path not allowed '/mydir'
When a user creates an external table and specifies a data object path that is in the allowed locations list, but the nz user does not have read or write access to the file, the CREATE EXTERNAL TABLE command succeeds, but commands to insert data to the table will fail with a permission error:
TESTDB.ADMIN(ADMIN)=> CREATE EXTERNAL TABLE my_ext_tbl SAMEAS tbl_retail
USING (DATAOBJECT ('/tmp/ext_tbl'));
CREATE EXTERNAL TABLE
TESTDB.ADMIN(ADMIN)=> INSERT INTO my_ext_tbl VALUES (1,2,3,4);
ERROR: /tmp/ext_tbl : Permission denied