Create DataBases and Tables


  • access the MySql monitor

     ex.: 

         mysql -u root -p


  • create and select a new database

     ex.: 

         Create Database accounting;

         Use accounting;


  • create the Invoice table

     ex.: 

        Create Table invoice(

                  invoice_no smallint(4) UNSIGNED NOT NULL AUTO_INCREMENT,

                  client_id smallint(3) UNSIGNED,

                  inv_date timestamp not null,

                  inv_amt decimal(10,2) UNSIGNED NOT NULL,

                  PRIMARY KEY (invoice_no),

                  INDEX (inv_date)

             );


  • create other table(s)

     ex.: 

        Create Table clients(

                  client_id smallint(3) UNSIGNED NOT NULL AUTO_INCREMENT,

                  name varchar(40) NOT NULL,

                  street varchar(40),

                  city varchar(25),

                  zip varchar(8),

                  phone varchar(15),

                  e_mail varchar(30),

                  PRIMARY KEY (client_id),

                  INDEX (name)

           );


  • confirm the existence of the table(s)

     ex.: 

        Show Tables;

        Show Columns from Invoice

        Show keys from invoice