Demo - Week 2
Part 1 - Log in to MySQL and view some data
| wget https://phpwebdevmysql.com/files/northwind.sql
|
- Log into your
mysql
server:
You are now in the mysql
command line interface (CLI):
- Create the
northwind
database with the following command:
| > create database northwind;
|
- Exit the
mysql
CLI by typing:
You are now back in the Bash shell:
- With the database created import the database files (we downloaded) with the following commands:
| mysql -u student -p northwind < northwind.sql
|
- Log back into your
mysql
server:
- Direct your
mysql
client to use the northwind
database:
- Describe all the columns in a table:
-
How many tables are there in the northwind database? ______
-
How many products are in the products table? ______
-
What is the unit price for the row with a product_name of Chai
______
Part 2 - Create a table in your own database schema
- Create a database using your MadisonCollege username. In this example I use my username of
kemarks1
:
| > create database kemarks1;
> use kemarks1;
|
- Create a table named
fullname
using the following statement:
| > CREATE TABLE fullname ( first_name varchar(20), last_name varchar(20) );
|
- Insert a row into the table
fullname
using the following statement:
| > INSERT INTO fullname (first_name, last_name) VALUES ('Ken', 'Marks');
|
| > SELECT * FROM fullname;
|
- Exit the
mysql
client by typing: