2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

postgreSQLでバイト指定で文字列を切り出す

Posted at

初めに

PostgreSQLには標準に用意されていない、バイト数指定で文字列を切り出す方法です。

substrbyte.sql
select 
  'あいうえお'
 ,substring('あいうえお'::bytea ,1,3) 
 ,substring('あいうえお'::bytea ,1,3)::text 
 --バイト指定で文字列を切り出す。
 ,convert_from(substring('あいうえお'::bytea ,4,3), 'UTF8')
 --※convert_fromは指定したencodingに変換できない場合エラー
 --,convert_from(substring('あいうえお'::bytea ,5,3), 'UTF8')

image.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?