January 8, 2003

Create a Table via Terminal in MySQL

Creating a Table in MySQL can be a little daunting, especially if you’re used to the GUI interfaces of other databases. (SQL, Access). But it’s not that hard.

Once you’re in MySQL, and in your database, simply use the CREATE TABLE statement to specify the layout of your table.

mysql> CREATE TABLE tony (name VARCHAR(20), when DATE, why CHAR(1));

What you’ve done is specify the table and columns, and column types. VARCHAR is a good generic choice when you’ve got text columns that will vary in length. Any length from 1 to 255 will work. (if you need to alter your choice later, MySQL provides an ALTER TABLE

The MySQL Site has a good listing of the MySQL Column Types to help you define those columns.

Post Info

Tagged As MySQL

Comments are Open (0)

Posted at 12:00 PM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu