27.13.2 データベースへのPgxFrameの格納

PgxFrameをデータベースに格納する場合、フレームは表として格納されます(列はPgxFrameの列に対応し、行はPgxFrameの行に対応します)。PgxFrameをデータベースに格納するときに、列の順序が維持される場合と維持されない場合があります。また、CLOBデータ型の列を含むPgxFrameをデータベースに格納できます。

次の例では、データベースにPgxFrameを格納する方法を示します。この例では、現在ログインしているスキーマにPgxFrameを格納することを前提としています。

opg4j> rsFrame.write().
           db().                     // select the "format" to be relational db
           name("F1").               // name of the frame
           tablename("T1").          // 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
           store()
rsFrame.write()
    .db()            // select the "format" to be relational db            
    .name("F1")      // name of the frame        
    .tablename("T1") // 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      
    .store();
>>> (
...     rs_frame.write().
...     name('F1').       # name of the frame
...     db().             # select the "format" to be relational db
...     table_name('T1'). # 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
...     store()
... )

あるいは、次の例に示すように、PgxFrameを別のスキーマに格納することもできます。別のスキーマに書き込む場合は、CREATE TABLE権限を持っていることを確認してください。

// store as table in the database using jdbc + username + password
opg4j> rsFrame.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("<db_username>").
           password("<password>").
           store()
rsFrame.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("<db_username>")
    .password("<password>")
    .store();
>>> (
...     rs_frame.write().
...     name('frame_name').        # name of the frame
...     db().                      # select the "format" to be relational db
...     table_name('table_name').  # 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
...     jdbc_url("<jdbc_url>").
...     username("<db_username>").
...     password("<password>").
...     store()
... )