主キー
getPrimaryKeys メソッドを使用すると、Google Drive テーブルの主キーに関する情報を返すことができます。結果は、テーブル名に基づいて制限できます。
次のコード例は、Files テーブルの主キーを構成するカラムを出力します。
String connectionString = "jdbc:googledrive:InitiateOAuth=GETANDREFRESH;OAuthClientId=myClientId;OAuthClientSecret=myClientSecret;OAuthSettingsLocation=myOAuthSettings.txt;";
Connection conn = DriverManager.getConnection(connectionString);
ResultSet rs = conn.getMetaData().getPrimaryKeys(null,null,"Files");
while(rs.next()){
System.out.println(rs.getString("COLUMN_NAME"));
}
getPrimaryKeys メソッドは次のカラムを返します。
| カラム名 | データ型 | 説明 |
| TABLE_CAT | String | テーブルカタログ。 |
| TABLE_SCHEM | String | テーブルスキーマ。 |
| TABLE_NAME | String | テーブル名。 |
| COLUMN_NAME | String | カラム名。 |
| KEY_SEQ | short | 外部キー内のシーケンス番号(1から始まるカラムインデックス)。 |
| PK_NAME | String | 主キー名。 |