From: Martijn Tonies Date: December 31 2003 9:46am Subject: Re: Create Tables In MySQL List-Archive: http://lists.mysql.com/mysql/156562 Message-Id: <010e01c3cf82$f27d4560$0e02a8c0@martijn> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi Caroline, > 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 AUTO_INCREMENT PRIMARY KEY); There's no difference in INT or INTEGER - see http://www.mysql.com/doc/en/Column_types.html > 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? VARCHAR has a maximum length of 255 characters, although I think this is increased in a later MySQL version. If you want to store "unlimited" amounts of text, use a blob (or blob like) column type, eg: MEDIUMTEXT or LONGTEXT See http://www.mysql.com/doc/en/Column_types.html for details. > 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? To store date/time values, use the DATETIME type. See http://www.mysql.com/doc/en/DATETIME.html With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com