Website Construction Summary (Cont.)

  1. Entering Data into a Database
  2. SQL (Structured Query Language) is a standard language for accessing and manipulating databases. The list below shows how to use MySQL text monitor to create a database. The SQL commands can be found from here.

    Note that MySQL text monitor is not working yet. Use MySQL Workbench instead.

    An Example of MySQL Database Processing
    
     undcemcs02> mysql -h undcsmysql.mysql.database.azure.com -u userid -p 
      Enter password: ********** 
    
      Welcome to the MySQL monitor.  Commands end with ; or \g.
      Your MySQL connection id is 2140
      Server version: 5.1.73 Source distribution
      Copyright (c) 2000, 2012, MySQL and/or its affiliates.
      All rights reserved. MySQL is a registered trademark of
      MySQL Corporation and/or its
      affiliates. Other names may be trademarks of their
      respective owners.
    
      Type 'help;' or '\h' for help. Type '\c' to clear the
      current input statement.
    
      mysql> show databases; 
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | wenchen            |
      +--------------------+
      2 rows in set (0.00 sec)
    
      mysql> -- Comment: wenchen is the instructor’s database 
      mysql> use wenchen; 
      Database changed
    
      mysql> DROP TABLE IF EXISTS student3;
      Query OK, 0 row affected (0.234 sec)
    
      mysql> CREATE TABLE student3 ( 
          ->   name     VARCHAR(32) PRIMARY KEY, 
          ->   city     VARCHAR(16) NOT NULL, 
          ->   country  VARCHAR(16) NOT NULL ); 
      Query OK, 0 rows affected (0.219 sec)
    
      mysql> INSERT INTO student3 VALUES ( 'Alfreds Futterkiste', 'Berlin', 'Germany' ); 
      Query OK, 1 row affected (0.141 sec)
    
      mysql> INSERT INTO student3 VALUES ( 'Berglunds snabbköp', 'Luleå', 'Sweden' ); 
      Query OK, 1 row affected (0.141 sec)
    
      mysql> INSERT INTO student3 VALUES ( 'Centro comercial Moctezuma', 'México D.F.', 'Mexico' ); 
      Query OK, 1 row affected (0.141 sec)
    
      mysql> INSERT INTO student3 VALUES ( 'Ernst Handel', 'Graz', 'Austria' ); 
      Query OK, 1 row affected (0.141 sec)
    
      mysql> INSERT INTO student3 VALUES ( 'FISSA Fabrica Inter. Salchichas', 'Madrid', 'Spain' ); 
      Query OK, 1 row affected (0.141 sec)
    
      mysql> SELECT * FROM student3; 
      +---------------------------------+-------------+-----------+
      | name                            | city        | country   |
      +---------------------------------+-------------+-----------+
      | Alfreds Futterkiste             | Berlin      | Germany   |
      | Berglunds snabbköp              | Luleå       | Sweden    |
      | Centro comercial Moctezuma      | Mexico D.F. | Mexico    |
      | Ernst Handel                    | Graz        | Austria   |
      | FISSA Fabrica Inter. Salchichas | Madrid      | Spain     |
      +---------------------------------+-------------+-----------+
      5 rows in set (0.031 sec)
    
      mysql> commit; 
      Query OK, 0 rows affected (0.00 sec)
    
      mysql> exit; 
      Bye
    
     undcemcs02>

    The italic white text with a navy background color is entered by users.




      It is always darkest before the dawn.