University of Cincinnati logo and link  
Handy MySQL Commands
 
  UC ingot
  • [MySQL_Home]\bin\mysql opens a command-line interface to MySQL.
    • SHOW DATABASES; generates a list of databases.
    • USE database_name switches to the named database.
  • Commands for creating a database:
    • GRANT ALL ON students.* TO your_mysql_name; - An administrative function.
    • CREATE DATABASE students; - creates the database.
    • USE students - switches to that database.
  • Putting tables in your database
    • SHOW TABLES; - show the tables in the database.
    • CREATE TABLE student (name VARCHAR(20), bearcatID VARCHAR(8),

    •     -> major VARCHAR(20), gender CHAR(1));
      creates the table and specifies its colums.
      • VARCHAR is a good choice when the columns will vary in length.  They cannot exceed the number you provide with VARCHAR.  This number can be anything from 1 to 255.
    • DESCRIBE student;

    • lists columns and types for student.
    • INSERT INTO student VALUES ("Brandan", "jonesbr", "MBA", "M");

    • inserts a row into table student.
  • The SELECT statement....
    • SELECT what_to_select

    • FROM which_table
      WHERE conditions_to_satisfy

      * selects all rows from the table.

 Setting up Connector/J