1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DuckDBでSELECTを実行したときに長い文字列をすべて表示したい

Posted at

DuckDBをコマンドラインから実行してselect文を発行するときに、デフォルトの出力フォーマットでは列に保存されている文字列が長すぎて省略されてしまうことがあります。MySQLでは、select文の最後の";"を"\G"に置き換えることで出力フォーマットを変更できますが、DuckDBでも同様の機能が用意されています。
select文の出力フォーマットを変えるには.modeドットコマンドが使えます。事前にコマンドを実行して出力フォーマットを変えてからselect文を実行すると、出力フォーマットが変わります。

D select view_name, sql from duckdb_views() where view_name='vending_machine';
┌─────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────┐
    view_name                                                    sql                                                 
     varchar                                                   varchar                                               
├─────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────┤
 vending_machine  CREATE VIEW sales_report_warehouse.vending_machine AS WITH final AS (SELECT CAST(id AS INTEGER)   
└─────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┘
D .mode line
D select view_name, sql from duckdb_views() where view_name='vending_machine';
view_name = vending_machine
      sql = CREATE VIEW sales_report_warehouse.vending_machine AS WITH final AS (SELECT CAST(id AS INTEGER) AS id, "name", address FROM dev.sales_report_source.vending_machine)SELECT * FROM final;
D

なお、デフォルトの出力フォーマットに戻したい時には.mode duckboxを実行します。

参考URL
Output Formats

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?