Java Reference
In-Depth Information
stmt = con.createStatement();
stmt.execute(SQLCommand);
con.close();
}
catch(SQLException e){
System.err.println(e.getMessage());
}
finally {
try {
if (con != null) {
con.close();
}
if (stmt !=null) {
stmt.close();
}
} catch (Exception ex) { // ignore }
}
}
public static void main(String[] args) {
TableMaker tableMaker = new TableMaker();
tableMaker.execute(SQLCreate);
}
}
Compile and execute the example, and you should be able to see the new table in your database.
Using a GUI-based system, you are able to see the table when you open the database. With a
command line DBMS like MySQL, you need to type the following at the command prompt:
SHOW TABLES;
In addition to creating a table, you may find it necessary to alter an existing table. This can be done
using the ALTER TABLE command.
Altering a Table with ALTER TABLE
Now that you have built your table, it looks as if you should have included fields for phone number and
e-mail address. Many database management systems let you use SQL to modify tables with the
ALTER TABLE command. The ALTER TABLE command enables you to do these two things:
 
Add a column to an existing table
Search WWH ::




Custom Search