5. Populating Tables : COPY Statement Syntax : File Name Specification on the COPY Statement
 
Share this page                  
File Name Specification on the COPY Statement
Only one file can be specified in the copy operation. If the file does not exist when copying to a file, it is created.
Windows: If the file exists, COPY overwrites it. When specifying a file name, always enclose it in single quotation marks. Omit the drive and directory portion of the file name if the file is in the current directory. Otherwise, provide a full path name with drive and directory. The following example shows a full path name; this is an example of unformatted copying (see Unformatted Copying):
COPY emp() FROM 'D:\users\fred\emp.lis’;
UNIX: If the file exists, COPY overwrites it. When specifying a file name, always enclose it in single quotation marks. Omit the full path name if the file is in the current directory. Otherwise, provide a full path name. The following example shows a full path name; this is an example of unformatted copying (see Unformatted Copying):
COPY emp() FROM '/usr/fred/emp.lis';
Important!  The COPY statement is not able to expand $HOME or recognize the UNIX variables set in your environment. Do not use these variables to specify a path name for the COPY statement. For example, the following COPY statements do not work:
COPY emp () FROM '~fred/emp.lis';     /* invalid */
COPY emp () FROM '$HOME/emp.lis';     /* invalid */
VMS: If the file exists, COPY creates another version of the file. When specifying a file name, you can optionally give a VMS file type:
INTO | FROM 'filename[, filetype]'
where filetype is text, binary, or variable.