Tuesday, 12 February 2013

Adding Table and Inserting values


The SQL command used to create a new table in a database typically looks like this:
CREATE TABLE table-name (field-name-1 field-type-1 modifiers,
field-name-2 field-type-2 modifiers, ... , field-name-n
field-type-n modifiers)

The table name cannot contain spaces, slashes, or periods; other than this, any
character is fair game. Each table (and the data it contains) is stored as a set of three
files in your MySQL data directory.

Here’s a sample command to create the members table in the example you saw a
couple sections back:
mysql> CREATE TABLE members (member_id int(11) NOT NULL auto_increment,
fname varchar(50) NOT NULL, lname varchar(50) NOT NULL, tel varchar(15),
email varchar(50) NOT NULL, PRIMARY KEY (member_id));