• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

creating table

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just learning Java, through a college course. I have been given an assignment to create two tables and populate them with information. I have spent a litte time searching the API hoping for some help but I didn't really know where to start looking. What I need to know first is how to create the table. I know to use ("CREATE TABLE <table name> ()"); Do I put the name of each column in the ()? Are they separated by commas? Along with the name do I put the type and the size?
I have more questions if you don't mind helping, but this could get me started.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd recommend taking a look at The Creating Tables section at SQLCourse.com.
And perhaps a simple example will help. The following SQL statement would work to create a new table named student with three columns - idNo, fName, and lName - in a MySQL database.
create table student (
  idNo varchar(11) not null,
  fName varchar(32),
  lName varchar(32)
);
This statement specifies that idNo is a char field up to 11 characters big that is not allowed to be empty (not null). fName and lName are fields up to 32 characters each.
Available column types do differ between different database vendors. For example, Oracle has a column type called varchar2, while MySQL does not. So, a table creation statement for one database vendor might not work on another.
When figuring out table creation statements, it can be nice to have the documentation at hand. The documentation for the MySQL Column Types can be found at http://www.mysql.com/doc/en/Column_types.html
Figuring it out?
[ April 26, 2003: Message edited by: Dirk Schreckmann ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic