Creating a Doris Table
This section describes the sample code for creating a Doris table.
The following code snippet is in the JDBCExample class.
Run the SQL statement in Java JDBC mode to create the table corresponding to tableName in the database corresponding to the dbName variable in the cluster.
String createTableSql = "create table if not exists " + dbName + "." + tableName + " (\n" +
"c1 int not null,\n" +
"c2 int not null,\n" +
"c3 string not null\n" +
") engine=olap\n" +
"unique key(c1, c2)\n" +
"distributed by hash(c1) buckets 1"; public static void execDDL(Connection connection, String sql) throws Exception {
try (PreparedStatement statement = connection.prepareStatement(sql)) {
statement.execute();
} catch (Exception e) {
logger.error("Execute sql {} failed.", sql, e);
throw new Exception(e);
}
} What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot