14.13.5 データベースへのPgxFrameの格納
PgxFrame
をデータベースに格納する場合、フレームは表として格納されます(列はPgxFrame
の列に対応し、行はPgxFrame
の行に対応します)。
ノート:
PgxFrame
をデータベースに格納するときに、列の順序が維持される場合と維持されない場合があります。
上書きモード
データベースに表として格納する場合、既存の表(正しい構造のもの)を上書きできます。
上書きモードでは、前の表が切り捨てられた(空にされた)後、データが挿入されます。デフォルトではfalse
に設定されており、overwrite
をtrue
に設定しないかぎり、表がすでに存在する場合はユーザーにエラーがスローされます。
// store as table in the database using jdbc + username + password
opg4j> exampleFrame.write().
db(). // select the "format" to be relational db
name("framename"). // name of the frame
tablename("tablename"). // name of the table in which the data must be stored
overwrite(true). // indicates that if there is a table with the same name, it will be overwritten (truncated)
connections(16). // indicates that 16 connections can be used to store in parallel
jdbcUrl("jdbcUrl").
username("user").
password("password").
store()
exampleFrame.write()
.db() // select the "format" to be relational db
.name("framename") // name of the frame
.tablename("tablename") // name of the table in which the data must be stored
.overwrite(true) // indicates that if there is a table with the same name, it will be overwritten (truncated)
.connections(16) // indicates that 16 connections can be used to store in parallel
.jdbcUrl("jdbcUrl")
.username("user")
.password("password")
.store();
親トピック: PgxFrameの表形式データ構造