• 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

Create Table in MySQL

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have several simple questions regarding creating tables in the MySQL.
1. For a variable of Java primitive int type, I should use INT or INTEGER? Do I have to specify the length of the field?
CREATE TABLE message_thread( thread_id INT or INTEGER NOT NULL );
2. A field in my table is for storing articles. Articles could be very long in variable length. I should use VARCHAR or TEXT? What about the length of the field?
3. For a variable of the Timestamp type, do I specify
CREATE TABLE message_thread( thread_creation_date TIMESTAMP NOT NULL );
What about the length of the field?
Thanks for your advices in advance.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MySql has some excelent documentation
which answers your questions.

Originally posted by JiaPei Jen:

1. For a variable of Java primitive int type, I should use INT or INTEGER?
CREATE TABLE message_thread( thread_id INT or INTEGER NOT NULL );


From the documentation:


"M" Indicates the maximum display size. The maximum legal display size is 255.
INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
INTEGER[(M)] [UNSIGNED] [ZEROFILL]
This is a synonym for INT.


Originally posted by JiaPei Jen:

Do I have to specify the length of the field?


Again, from the documentation:


Square brackets (`[' and `]') indicate parts of type specifiers that are optional.


And so on.
[ December 31, 2003: Message edited by: Joe Ess ]
reply
    Bookmark Topic Watch Topic
  • New Topic