Wednesday, January 28, 2009

How To Create Table

The table is where all of the data is stored in a particular database. Because we are working with a relational database system, the data is stored in rows and columns. Our goal in creating a table is to determine what will be stored in each table column. Once this information has been established, we can decide on the column types and potential sizes.



Once we have identified all of the fields and assigned each a type, we can create the table. To create a table, use this command:




mysql> create table person (

id int primary key,

username varchar(20),

password varchar(15)

Query OK, 0 rows affected (0.00 sec)



We can see all of the tables in our database with the following command:



mysql> show tables;

+--------------------+

Tables_in_samples

+--------------------+

person

+--------------------+

1 row in set (0.00 sec)