Skip to content

Instantly share code, notes, and snippets.

@jimathyp
Last active May 25, 2021 23:30
Show Gist options
  • Select an option

  • Save jimathyp/c819d92302fc4e921dd163c7106dcdfe to your computer and use it in GitHub Desktop.

Select an option

Save jimathyp/c819d92302fc4e921dd163c7106dcdfe to your computer and use it in GitHub Desktop.

PSQL usage

creating tab-delimited output for file

psql -F '\t' -c "select from x"-o output.tab

# -F wants the actual literal character

# Need to use an 'actual' tab (or newline)
# this depends on the shell
# bash:
psql -F $'\t'
# $ will expand the string with the backslash escaped characters replaced by the ANSI C Standard
# the expanded result is single quotes
  
# May need to use -A for unaligned output as well

# Or, in unix type
ctrl-V tab

# ctrl-v means not to interpret the next key.
# also works with other special keys (carriage returns ^M) and arrow keys

# or for the interactive psql shell
\f '\t'

https://stackoverflow.com/questions/10315916/how-to-set-tab-delimiter-using-psql-f https://www.postgresql.org/message-id/455C54FE.5090902@numerixtechnology.de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment