Create Tables

Create a Table

This tutorial provides an example on how to create a table using JDBC application.


Before going into the program, it is advised to go through JDBC Programming Basic Steps where the meaning of Connection, Statement etc. are discussed.


import java.sql.*;
 * @author ashok.mariyala
public class CreateTableDemo { 
   public static void main(String[] args) throws Exception {
      String sqlQuery = "create table emp(eno number,ename varchar2(20),esal number,eaddr varchar2(50))"; 
      Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger"); 
      Statement st = con.createStatement();
      ResultSet rs = st.executeUpdate(sqlQuery);
      System.out.println("Table Created Successfully");
Create Tables
Scroll to top