创建数据表
最近更新时间: 2024-10-17 17:10:00
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class createtable {
public static void main( String args[] )
{
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:15432/postgres?binaryTransfer=false","tbase", "tbase");
System.out.println("Opened database successfully");
stmt = c.createStatement();
String sql = "create table public.tbase(id int,nickname text) distribute by shard(id) to group default_group" ;
stmt.executeUpdate(sql);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName()+": "+ e.getMessage() );
System.exit(0);
}
System.out.println("Table created successfully");
}
}
编译
javac createtable.java
执行
java createtable
注意:
连接url中禁止使用currentSchema=xxxx来指定当前搜索路径。