Sunday, November 8, 2015

1.15 What are special characters and how does copy load then as literals?

COPY: What are special characters and how does copy load then as literals?

The default COPY statement escape key is a backslash (\).

By preceding any special character with an escape character, COPY interprets the character that follows literally, and copies it into the database.

These are the special characters that you escape to load them as literals:
  1. DELIMITER character (default is |)
  1. NULL character (Default is empty string '')
  1. Escape character (Default is  \)
  1. New line and other control characters.

To use a special character as a literal, prefix it with an escape character.
For example, to include a literal backslash (\) in the loaded data (such as when including a file path), use two backslashes (\\).


COPY removes the escape character from the input when it loads escaped characters. 

No comments:

Post a Comment