insert.sh

#!/bin/bash

echo "TRUNCATE TABLE test" | psql alextest -h lab100 -U smoc
echo ""

# server db = UTF8
# client conn = UTF8
export PGCLIENTENCODING=UTF8
# client env
export LANG=zh_TW.UTF-8
export LC_ALL=zh_TW.UTF-8

# no convert
echo "s-utf8 c-utf8 txt-big5"
echo "insert into test(name)values('s-utf8 c-utf8 txt-big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-big5
echo ""
echo "s-utf8 c-utf8 txt-utf8"
echo "insert into test(name)values('s-utf8 c-utf8 txt-utf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-utf8


# convert
echo ""
echo "s-utf8 c-utf8 txt-big5toutf8"
echo "insert into test(name)values('s-utf8 c-utf8 txt-big5toutf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-big5toutf8

echo "#########################################################################"
echo "insert into test(name)values('#####################');" | psql alextest -h lab100 -U smoc

# server db = UTF8
# client conn = BIG5
export PGCLIENTENCODING=BIG5
# client env
export LANG=zh_TW.UTF-8
export LC_ALL=zh_TW.UTF-8

# no convert
echo "s-utf8 c-big5 txt-utf8"
echo "insert into test(name)values('s-utf8 c-big5 txt-utf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-utf8
echo ""
echo "s-utf8 c-big5 txt-big5"
echo "insert into test(name)values('s-utf8 c-big5 txt-big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-big5


# convert
echo ""
echo "s-utf8 c-big5 txt-utf8 to big5"
echo "insert into test(name)values('s-utf8 c-big5 txt-utf8 to big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-utf8tobig5

評論: 0 | 引用: 0 | 閱讀: 1001 | 列印 | 文件 | 轉發

發表評論
暱 稱: 密 碼:
網 址: E - mail:
驗證碼: 驗證碼圖片 選 項:
頭 像:
內 容:
  • 粗體
  • 斜體
  • 底線
  • 插入圖片
  • 超連結
  • 電子郵件
  • 插入引用
  • 表情符號