23.03.2017 Views

wilamowski-b-m-irwin-j-d-industrial-communication-systems-2011

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

62-8 Industrial Communication Systems<br />

TABLE 62.1<br />

SQL Database Table<br />

Last Name First Name Employee Department Employee ID<br />

Rives John Sales 2<br />

Tent Tom Accounts 1<br />

Hold Tim Technical 5<br />

After installing MySQL server, open command line to run the MySQL client program. To connect to<br />

your MySQL server, here’s what you should type:<br />

mysql -h -u -p <br />

If you installed and typed everything properly, the MySQL client program will introduce itself and<br />

then take you to the MySQL command line:<br />

mysql><br />

If at any time you want to exit the MySQL client program, just type “quit” or “exit.”<br />

62.4.1 Creating a Database<br />

To create a database and use it, type the following command (don’t forget the semicolon), then ENTER.<br />

Ex:<br />

mysql> CREATE DATABASE databasename;<br />

mysql> USE databasename;<br />

mysql> CREATE DATABASE employee;<br />

mysql> USE employee;<br />

To see a list of databases available, type the following command, then ENTER.<br />

mysql> SHOW DATABASES;<br />

62.4.2 Creating a Table<br />

To create a table, use the “CREATE TABLE” statement.<br />

Syntax:<br />

CREATE TABLE (<br />

column_name1 data_type,<br />

column_name2 data_type,<br />

);<br />

Example:<br />

mysql> CREATE TABLE employeeinfo (<br />

LastName varchar(15),<br />

FirstName varchar(15),<br />

Department varchar(15),<br />

Employee_ID int<br />

);<br />

© <strong>2011</strong> by Taylor and Francis Group, LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!